結果
問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
ユーザー |
|
提出日時 | 2021-05-21 14:24:26 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,175 bytes |
コンパイル時間 | 3,556 ms |
コンパイル使用メモリ | 77,604 KB |
実行使用メモリ | 59,048 KB |
最終ジャッジ日時 | 2024-10-10 07:29:23 |
合計ジャッジ時間 | 17,508 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 44 WA * 3 |
ソースコード
import java.util.Scanner; import java.util.List; import java.util.ArrayList; public class No1360 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); List<Integer> A = new ArrayList<Integer>(); for (int i=0; i < N; i++) { A.add(scan.nextInt()); } List<List<Integer>> B = new ArrayList<List<Integer>>(); for (int i=0; i < N; i++) { List<Integer> l = new ArrayList<Integer>(); for (int j=0; j < N; j++) { l.add(scan.nextInt()); } B.add(l); } scan.close(); long Max = Long.MIN_VALUE; int Max_comb = -1; for (int i=0; i < 1 << N; i++) { long point = 0; List<Integer> prev = new ArrayList<Integer>(); for (int j=0; j < N; j++) { if ((i & (1 << j)) != 0) { point += A.get(j); for (int p : prev) { point += B.get(p).get(j); } prev.add(j); } } if (Max < point) { Max = point; Max_comb = i; } } List<String> J = new ArrayList<String>(); for (int j=0; j < N; j++) { if ((Max_comb & (1 << j)) != 0) { J.add(String.valueOf(j+1)); } } System.out.println(Max); System.out.println(String.join(" ", J)); } }