Submission #1792103


Source Code Expand

#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 2200000 
#define MAXCARDS 100000

long long alNumber[MAXCARDS];
long long alTimes[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	int i=0;
	int j=0;
	long long lTemp2=0;
	long long lKinds=0;
/*	double  lLoopEnd=0.0;
	double  lTemp=0.0;
	double  lAllSum=0.0;
	double  lLeftSum=0.0;
	double  lRightSum=0.0;
	double  lTempMin=0.0;
	double  lMin=0.0; */
	long long  lCardsNumber =0;
	long long  lMax = 0;
	long long  lTop = 0;
	long long  lSecond = 0;
	long long  lSquare = 0;
	long long  lTarget=0;
	long long  lFound=0;
	long long  lAnswer=0;
	long long  lTimes=0;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (i=0;i<lCardsNumber;i++){
		alNumber[i]=0;
		alTimes[i]=0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<lCardsNumber;i++){
		lTemp2=atol(psInput);
		lFound=0;
		for (j=0;j<lKinds;j++){
			if(alNumber[j]==lTemp2){
				alTimes[j]=alTimes[j]+1;
				lFound=1;
			}
		}
		if (lFound==0){
			alNumber[lKinds]=lTemp2;
			alTimes[lKinds]=alTimes[lKinds]+1;
			lKinds++;
		}
		if (lMax<lTemp2){
			lMax=lTemp2;
		}
		if (i<lCardsNumber){
			psInput = strtok(NULL," ");
		}
	}

	for (lTarget=lMax;lTarget>0;lTarget--){
		lTimes=0;
		for(j=0;j<lKinds;j++){
			if(alNumber[j]==lTarget){
				lTimes=alTimes[j];
			}
		}

		if(lTimes>=4&&lSquare==0){
			lSquare=lTarget;
		} 
		if(lTimes>=2){
			if(lTop==0){
				lTop=lTarget;
			} else if (lSecond==0) {
				lSecond=lTarget;
			}
		}
		if(lTarget+10<lSecond||lTarget+10<lSquare){
			break;
		}
	}
	lAnswer=lTop*lSecond;
	if (lAnswer<lSquare*lSquare){
			lAnswer=lSquare*lSquare;
	}
	printf("%ld\n",lAnswer);

    return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User unirita137
Language C (GCC 5.4.1)
Score 0
Code Size 1896 Byte
Status TLE
Exec Time 2103 ms
Memory 2688 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:39:2: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
  gets(sInput);
  ^
./Main.c:97:9: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
  printf("%ld\n",lAnswer);
         ^
/tmp/cc68unfW.o: In function `main':
Main.c:(.text.startup+0x10): 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 × 10
TLE × 5
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt TLE 2103 ms 2688 KB
2.txt AC 1121 ms 1408 KB
3.txt TLE 2103 ms 2688 KB
4.txt TLE 2103 ms 2688 KB
5.txt AC 7 ms 1408 KB
6.txt TLE 2103 ms 2688 KB
7.txt AC 15 ms 2688 KB
8.txt AC 7 ms 1152 KB
9.txt TLE 2103 ms 1408 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB
sample3.txt AC 1 ms 128 KB