結果

問題 No.851 テストケース
ユーザー shigeki_createshigeki_create
提出日時 2019-08-15 03:32:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 3,153 ms
コード長 776 bytes
コンパイル時間 2,456 ms
コンパイル使用メモリ 79,496 KB
実行使用メモリ 57,548 KB
最終ジャッジ日時 2023-10-19 18:28:26
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,472 KB
testcase_01 AC 132 ms
57,464 KB
testcase_02 AC 132 ms
57,500 KB
testcase_03 AC 131 ms
57,548 KB
testcase_04 AC 133 ms
57,184 KB
testcase_05 AC 131 ms
57,436 KB
testcase_06 AC 134 ms
57,436 KB
testcase_07 AC 135 ms
57,208 KB
testcase_08 AC 136 ms
57,268 KB
testcase_09 AC 137 ms
57,500 KB
testcase_10 AC 137 ms
57,492 KB
testcase_11 AC 135 ms
57,500 KB
testcase_12 AC 134 ms
57,500 KB
testcase_13 AC 133 ms
55,736 KB
testcase_14 AC 133 ms
57,544 KB
testcase_15 AC 132 ms
56,980 KB
testcase_16 AC 136 ms
57,420 KB
testcase_17 AC 132 ms
57,464 KB
testcase_18 AC 133 ms
55,384 KB
testcase_19 AC 136 ms
57,416 KB
testcase_20 AC 132 ms
57,500 KB
testcase_21 AC 136 ms
57,132 KB
testcase_22 AC 137 ms
57,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

		int N = Integer.parseInt(sc.nextLine());

		Long[] A = new Long[N];

		for(int i=0; i<N; i++) {
			String str = sc.nextLine();
			if(str.split(" ").length > 1) {
				println("\"assert\"");
				return;
			}
			A[i] = Long.parseLong(str);
		}

		List<Long> sum = new ArrayList<>();

		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				Long result = A[i] + A[j];
				if(!sum.contains(result)) sum.add(result);
			}
		}

		Collections.sort(sum, Comparator.reverseOrder());

		System.out.println(sum.get(1));
	}

	public static void print(Object o) {
		System.out.print(o);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}
0