結果
問題 | No.851 テストケース |
ユーザー |
![]() |
提出日時 | 2019-08-15 03:32:57 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 116 ms / 3,153 ms |
コード長 | 776 bytes |
コンパイル時間 | 2,132 ms |
コンパイル使用メモリ | 79,364 KB |
実行使用メモリ | 54,036 KB |
最終ジャッジ日時 | 2024-09-19 14:47:27 |
合計ジャッジ時間 | 5,420 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
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); } }