結果
問題 |
No.699 ペアでチームを作ろう2
|
ユーザー |
![]() |
提出日時 | 2020-01-07 12:07:35 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,243 bytes |
コンパイル時間 | 2,977 ms |
コンパイル使用メモリ | 77,348 KB |
実行使用メモリ | 88,068 KB |
最終ジャッジ日時 | 2024-11-23 00:48:53 |
合計ジャッジ時間 | 26,358 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 11 |
ソースコード
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); } for (int i = 0; i < n - 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; } } }