結果

問題 No.851 テストケース
コンテスト
ユーザー shigeki_create
提出日時 2019-08-15 03:32:57
言語 Java
(openjdk 26.0.2.1)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 56 ms / 3,153 ms
+ 659µs
コード長 776 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,000 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 45,512 KB
最終ジャッジ日時 2026-08-31 03:25:00
合計ジャッジ時間 4,828 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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