Submission #1789320


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

double alCards[MAXCARDS];
char sInput[MAX_STRING];

int main() {

	char* psInput;
	long long l=0;
	long long lTemp2=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;

	// read line 1
	gets(sInput);
	lCardsNumber = atol(sInput);
	//format
	for (l=0;l<lCardsNumber;l++){
		 alCards[l]=0;
	}
	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (l=0;l<lCardsNumber;l++){
		lTemp2=atol(psInput);
		alCards[lTemp2-1]=alCards[lTemp2-1]+1;
		if (lMax<lTemp2){
			lMax=lTemp2;
		}
		psInput = strtok(NULL," ");
	}

	for (lTarget=lMax;lTarget>0;lTarget--){
		if(alCards[lTarget-1]>=4&&lSquare==0){
			lSquare=lTarget;
		} else if(alCards[lTarget-1]>=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 1478 Byte
Status RE
Exec Time 101 ms
Memory 1920 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:34:2: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
  gets(sInput);
  ^
./Main.c:70:9: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘long long int’ [-Wformat=]
  printf("%ld\n",lAnswer);
         ^
/tmp/cczT0LQ6.o: In function `main':
Main.c:(.text.startup+0xc): 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 × 6
RE × 9
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 RE 99 ms 1920 KB
2.txt RE 100 ms 1024 KB
3.txt RE 100 ms 1920 KB
4.txt RE 101 ms 1920 KB
5.txt RE 99 ms 1024 KB
6.txt RE 98 ms 1920 KB
7.txt RE 100 ms 1920 KB
8.txt RE 98 ms 896 KB
9.txt RE 97 ms 1024 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 1 ms 128 KB
sample3.txt AC 1 ms 128 KB