Submission #1792312


Source Code Expand

#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 700000 
#define MAXCARDS 100000
#define MAXNUM 100000
int alNumber[MAXCARDS];
int alTimes[MAXNUM];
char sInput[MAX_STRING];
int compare(const int *val1, const int *val2);

int main() {

	char* psInput;
	int l=0;
	int i=0;
	int j=0;
	int lTemp2=0;
	int lKinds=0;
	int  lCardsNumber =0;
	int  lMax = 0;
	int  lTop = 0;
	int  lSecond = 0;
	int  lSquare = 0;
	int  lTarget=0;
	int  lFound=0;
	int  lAnswer=0;
	int  lTimes=0;
	int  lNumber=0;
	int  lBefore=0;
	int  lCount=0;
	int nFlag=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
//	for (i=0;i<MAXNUM;i++){
//		alNumber[i]=0;
//		alTimes[i]=0;
//	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		lTemp2=atol(psInput);
		alNumber[i]=lTemp2;
		if(lMax<lTemp2){
			lMax=lTemp2;
		}
		psInput = strtok(NULL," ");
	}
    qsort(alNumber, lCardsNumber, sizeof(int),
        (int (*)(const void *, const void *))compare
    );

	for (i=0;i<=lMax;i++){
		lCount=0;
		while(alNumber[j]==i){
			lCount++;
			j++;
		}
		alTimes[i]=lCount;
	}
	for (i=2;i<=lMax;i++){
		lTemp2=alTimes[i-2]+alTimes[i-1]+alTimes[i];
		if (lAnswer<lTemp2){
			lAnswer=lTemp2;
		}
	}

	printf("%d\n",lAnswer);

    return 0;
}

int compare(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Submission Info

Submission Time
Task C - Together
User unirita137
Language C (GCC 5.4.1)
Score 0
Code Size 1617 Byte
Status RE
Exec Time 102 ms
Memory 1588 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:37:2: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
  gets(sInput);
  ^
/tmp/ccLf0Wmr.o: In function `main':
Main.c:(.text.startup+0x12): warning: the `gets' function is dangerous and should not be used.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 8
RE × 1
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt
Case Name Status Exec Time Memory
0_000.txt AC 0 ms 128 KB
0_001.txt AC 0 ms 128 KB
0_002.txt AC 1 ms 512 KB
1_003.txt AC 1 ms 512 KB
1_004.txt RE 102 ms 892 KB
1_005.txt AC 12 ms 1492 KB
1_006.txt AC 13 ms 1588 KB
1_007.txt AC 16 ms 1532 KB
1_008.txt AC 19 ms 1532 KB