結果
問題 | No.698 ペアでチームを作ろう |
ユーザー | tenten |
提出日時 | 2022-10-19 09:39:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 82 ms / 1,000 ms |
コード長 | 1,807 bytes |
コンパイル時間 | 3,120 ms |
コンパイル使用メモリ | 74,064 KB |
実行使用メモリ | 52,968 KB |
最終ジャッジ日時 | 2023-09-12 00:03:31 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
49,452 KB |
testcase_01 | AC | 42 ms
49,820 KB |
testcase_02 | AC | 43 ms
49,728 KB |
testcase_03 | AC | 42 ms
49,348 KB |
testcase_04 | AC | 50 ms
49,360 KB |
testcase_05 | AC | 75 ms
51,752 KB |
testcase_06 | AC | 73 ms
52,308 KB |
testcase_07 | AC | 76 ms
52,968 KB |
testcase_08 | AC | 72 ms
51,772 KB |
testcase_09 | AC | 81 ms
51,632 KB |
testcase_10 | AC | 70 ms
52,332 KB |
testcase_11 | AC | 74 ms
52,268 KB |
testcase_12 | AC | 71 ms
50,248 KB |
testcase_13 | AC | 71 ms
52,608 KB |
testcase_14 | AC | 82 ms
52,012 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static int max = 0; static int[] values; static int n; 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(); } calc(0, new boolean[n], 0); System.out.println(max); } static void calc(int idx, boolean[] used, int sum) { if (idx >= n) { max = Math.max(max, sum); return; } for (int i = 0; i < n; i++) { if (used[i]) { continue; } used[i] = true; for (int j = i + 1; j < n; j++) { if (used[j]) { continue; } used[j] = true; calc(idx + 2, used, sum + (values[i] ^ values[j])); used[j] = false; } used[i] = false; break; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }