Submission #241572


Source Code Expand

Copy
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; ++i) {
			t[i] = scan.nextInt();
		}

		Arrays.sort(t);
		
		switch (n) {
			case 1 :
				System.out.println(t[0]);
				break;
			case 2 :
				System.out.println(Math.max(t[0], t[1]));
				break;
			case 3 :
				System.out.println(Math.max(t[2], t[0] + t[1]));
				break;
			case 4:
				int ans[] = new int[4];
				ans[0] = Math.max(t[0] + t[1], t[2] + t[3]);
				ans[1] = Math.max(t[0] + t[2], t[1] + t[3]);
				ans[2] = Math.max(t[0] + t[3], t[1] + t[2]);
				ans[3] = Math.max(t[0] + t[1] + t[2], t[3]);

				int answer = Integer.MAX_VALUE;
				
				for (int i = 0; i < 4; i++) {
					if (answer > ans[i]) {
						answer = ans[i];
					}
				}
				
				System.out.println(answer);
				break;
		}

		scan.close();

	}

}

Submission Info

Submission Time
Task A - 高橋君とお肉
User uriku
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1005 Byte
Status
Exec Time 426 ms
Memory 23452 KB

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 100 / 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 426 ms 23452 KB
subtask0-sample-02.txt 410 ms 23248 KB
subtask0-sample-03.txt 390 ms 23244 KB
subtask1-01.txt 389 ms 23224 KB
subtask1-02.txt 413 ms 23260 KB
subtask1-03.txt 403 ms 23216 KB
subtask1-04.txt 409 ms 23312 KB
subtask1-05.txt 387 ms 23320 KB
subtask1-06.txt 382 ms 23224 KB
subtask1-07.txt 379 ms 23252 KB
subtask1-08.txt 377 ms 23324 KB
subtask1-09.txt 377 ms 23304 KB
subtask1-10.txt 377 ms 23176 KB
subtask1-11.txt 383 ms 23280 KB
subtask1-12.txt 416 ms 23332 KB
subtask1-13.txt 383 ms 23320 KB
subtask1-14.txt 384 ms 23232 KB
subtask1-15.txt 382 ms 23372 KB
subtask1-16.txt 389 ms 23240 KB