Submission #241880


Source Code Expand

Copy
#include <stdio.h>

int main(void)
{
	int n, t[4], a, i,max, min,mj,mk, ch;
	scanf("%d", &n);

	for(i=0; i<n; i++){
		scanf("%d", &t[i]);
	}
	a = 0;
	if(n == 1)
		a = t[0];
	else{
		max = t[0];
		mj = 0;
		for(i = 1; i < n; i++){
			if(max < t[i]){
				max = t[i];
				mj = i;
			}
		}
		min = t[0];
		mk = 0;
		for(i = 1; i < n; i++){
			if(t[i] < min){
				min = t[i];
				mk = i;
			}
		}
		ch = 0;
		for(i = 0; i < n; i++){
			if(mj == i || mk == i)
				continue;
			ch += t[i];
		}
		if(n == 2){
			a = max;
		} else if(n == 3){
			a = min+ch;
			if(a < max)
				a = max;
			if(t[0] == t[1]&&t[0] == t[2])
				a -= t[0];
		} else{
			a = max;
			if((t[0] == t[1]) &&(t[0] == t[2]) && (t[0]==t[3]))
				;
			else
				ch += min; 
			if(a < ch){
				a += min;
				ch -= min;
				if(a < ch){
					a = ch;
				}
			}

		}

	}
	printf("%d\n", a);
	return 0;
}

Submission Info

Submission Time
Task A - 高橋君とお肉
User jte5121
Language C (GCC 4.6.4)
Score 0
Code Size 921 Byte
Status
Exec Time 27 ms
Memory 804 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:6:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
./Main.c:9:8: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt
All 0 / 100 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask0-sample-03.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask1-16.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt 24 ms 804 KB
subtask0-sample-02.txt 25 ms 704 KB
subtask0-sample-03.txt 23 ms 800 KB
subtask1-01.txt 24 ms 800 KB
subtask1-02.txt 23 ms 708 KB
subtask1-03.txt 24 ms 800 KB
subtask1-04.txt 22 ms 704 KB
subtask1-05.txt 24 ms 704 KB
subtask1-06.txt 25 ms 776 KB
subtask1-07.txt 22 ms 700 KB
subtask1-08.txt 22 ms 796 KB
subtask1-09.txt 23 ms 800 KB
subtask1-10.txt 22 ms 800 KB
subtask1-11.txt 27 ms 652 KB
subtask1-12.txt 24 ms 804 KB
subtask1-13.txt 26 ms 700 KB
subtask1-14.txt 25 ms 792 KB
subtask1-15.txt 25 ms 796 KB
subtask1-16.txt 23 ms 792 KB