結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
|
提出日時 | 2020-10-22 00:42:01 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 88 ms / 1,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 2,525 ms |
コンパイル使用メモリ | 76,920 KB |
実行使用メモリ | 38,068 KB |
最終ジャッジ日時 | 2024-07-21 09:11:44 |
合計ジャッジ時間 | 4,376 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); long a[] = new long[n]; String str[] = br.readLine().split(" "); for (int i = 0; i < n; i++) { a[i] = Long.parseLong(str[i]); } long dp[] = new long[1 << n]; dp[0] = 0; for (int bit = 0; bit < (1 << n); bit++) { for (int i = 0; i < n; i++) { if (((bit & (1 << i)) == 0)) continue; for (int j = i + 1; j < n; j++) { if (((bit & (1 << j)) == 0)) continue; long t = dp[bit - (1 << i) - (1 << j)] + (a[i] ^ a[j]); dp[bit] = Math.max(dp[bit], t); } } } System.out.println(dp[(1 << n) - 1]); } }