結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
|
| 提出日時 | 2020-07-26 14:33:04 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,098 bytes |
| コンパイル時間 | 20,575 ms |
| コンパイル使用メモリ | 380,272 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-06-28 15:15:22 |
| 合計ジャッジ時間 | 16,179 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 9 |
ソースコード
use std::cmp::max;
fn dfs(current: &mut Vec<usize>, used: &mut Vec<bool>, values: &Vec<usize>, n: usize) -> usize {
let mut result: usize = 0;
if current.len() == n / 2 {
return current.iter().fold(0usize, |acc, &x| acc ^ x);
}
for i in 0..n {
if used[i] { continue; }
for j in i+1..n {
if used[j] { continue; }
used[i] = true;
used[j] = true;
current.push(values[i] + values[j]);
result = max(result, dfs(current, used, values, n));
current.pop();
used[i] = false;
used[j] = false;
}
}
result
}
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut a = String::new();
std::io::stdin().read_line(&mut a).ok();
let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let mut current: Vec<usize> = vec![];
let mut used: Vec<bool> = vec![false; n];
println!("{}", dfs(&mut current, &mut used, &a, n));
}