結果
問題 | No.698 ペアでチームを作ろう |
ユーザー | tenten |
提出日時 | 2021-11-02 15:23:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 99 ms / 1,000 ms |
コード長 | 1,825 bytes |
コンパイル時間 | 1,872 ms |
コンパイル使用メモリ | 77,876 KB |
実行使用メモリ | 52,336 KB |
最終ジャッジ日時 | 2024-04-20 00:31:15 |
合計ジャッジ時間 | 3,722 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
50,336 KB |
testcase_01 | AC | 49 ms
50,196 KB |
testcase_02 | AC | 48 ms
49,908 KB |
testcase_03 | AC | 49 ms
50,384 KB |
testcase_04 | AC | 56 ms
50,504 KB |
testcase_05 | AC | 96 ms
52,144 KB |
testcase_06 | AC | 93 ms
52,276 KB |
testcase_07 | AC | 98 ms
52,168 KB |
testcase_08 | AC | 94 ms
52,112 KB |
testcase_09 | AC | 96 ms
52,108 KB |
testcase_10 | AC | 95 ms
52,336 KB |
testcase_11 | AC | 97 ms
52,124 KB |
testcase_12 | AC | 98 ms
52,084 KB |
testcase_13 | AC | 99 ms
51,936 KB |
testcase_14 | AC | 95 ms
52,308 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static int n; static int[] values; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); n = sc.nextInt(); values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } System.out.println(check1(0, new boolean[n])); } static int check1(int idx, boolean[] used) { if (idx == n) { return 0; } int ans = 0; for (int i = 0; i < n; i++) { if (!used[i]) { used[i] = true; ans = check2(idx + 1, used, values[i]); used[i] = false; break; } } return ans; } static int check2(int idx, boolean[] used, int v) { int max = 0; for (int i = 0; i < n; i++) { if (used[i]) { continue; } used[i] = true; max = Math.max(max, (v ^ values[i]) + check1(idx + 1, used)); used[i] = false; } return max; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }