結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
akakimidori
|
| 提出日時 | 2021-04-16 19:24:57 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 974 bytes |
| コンパイル時間 | 16,392 ms |
| コンパイル使用メモリ | 402,512 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-02 21:03:06 |
| 合計ジャッジ時間 | 14,677 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 3 WA * 9 |
ソースコード
// ---------- begin next_permutation ----------
fn next_permutation<T: Ord>(a: &mut [T]) -> bool {
a.windows(2).rposition(|a| a[0] < a[1]).map_or(false, |x| {
let y = a.iter().rposition(|b| a[x] < *b).unwrap();
a.swap(x, y);
a[(x + 1)..].reverse();
true
})
}
// ---------- end next_permutation ----------
fn read() -> Vec<u32> {
let mut s = String::new();
use std::io::Read;
std::io::stdin().read_to_string(&mut s).unwrap();
let mut it = s.trim().split_whitespace();
let mut next = || it.next().unwrap().parse::<u32>().unwrap();
let n = next();
(0..n).map(|_| next()).collect()
}
fn main() {
let mut a = read();
a.sort();
let mut ans = 0;
while {
let mut xor = 0;
for a in a.chunks_exact_mut(2) {
xor ^= a[0] + a[1];
a.sort_by_key(|a| !*a);
}
ans = ans.max(xor);
next_permutation(&mut a)
} {}
println!("{}", ans);
}
akakimidori