結果
問題 | No.699 ペアでチームを作ろう2 |
ユーザー | htensai |
提出日時 | 2020-01-07 12:10:57 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 909 ms / 1,000 ms |
コード長 | 1,271 bytes |
コンパイル時間 | 2,118 ms |
コンパイル使用メモリ | 74,380 KB |
実行使用メモリ | 59,632 KB |
最終ジャッジ日時 | 2023-08-14 23:13:43 |
合計ジャッジ時間 | 12,691 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,964 KB |
testcase_01 | AC | 125 ms
55,692 KB |
testcase_02 | AC | 156 ms
58,764 KB |
testcase_03 | AC | 122 ms
56,044 KB |
testcase_04 | AC | 170 ms
59,148 KB |
testcase_05 | AC | 902 ms
59,360 KB |
testcase_06 | AC | 909 ms
59,292 KB |
testcase_07 | AC | 903 ms
59,384 KB |
testcase_08 | AC | 908 ms
59,040 KB |
testcase_09 | AC | 902 ms
59,252 KB |
testcase_10 | AC | 896 ms
59,116 KB |
testcase_11 | AC | 891 ms
58,920 KB |
testcase_12 | AC | 891 ms
58,988 KB |
testcase_13 | AC | 879 ms
59,632 KB |
testcase_14 | AC | 874 ms
59,356 KB |
ソースコード
import java.util.*; public class Main { static int n; static int[] arr; static int max = Integer.MIN_VALUE; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); arr = new int[n]; for (int i = 0; i < n; i++ ){ arr[i] = sc.nextInt(); } search(1, new int[n]); System.out.println(max); } static void search(int count, int[] used) { if (count > n / 2) { int[] base = new int[n / 2 + 1]; for (int i = 0; i < n; i++) { base[used[i]] += arr[i]; } int ans = 0; for (int i = 1; i < base.length; i++) { ans ^= base[i]; } max = Math.max(ans, max); return; } for (int i = 0; i < count * 2 - 1; i++) { if (used[i] != 0) { continue; } used[i] = count; for (int j = i + 1; j < n; j++) { if (used[j] != 0) { continue; } used[j] = count; search(count + 1, used); used[j] = 0; } used[i] = 0; } } }