結果
問題 | No.1358 [Zelkova 2nd Tune *] 語るなら枚数を... |
ユーザー | tonyu0 |
提出日時 | 2021-01-22 22:38:27 |
言語 | Rust (1.77.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,213 bytes |
コンパイル時間 | 929 ms |
コンパイル使用メモリ | 150,956 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-08-27 20:38:05 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
ソースコード
use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec<i64> = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let b: Vec<Vec<i64>> = (0..n) .map(|_| { (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect() }) .collect(); let mut ans = -(1i64 << 60); let mut uuu: Vec<usize> = vec![]; for bit in 1..1 << n { let mut tmp = 0; let mut tmpu = Vec::new(); for i in 0..n { if bit >> i & 1 == 1 { tmp += a[i]; tmpu.push(i + 1); } } for i in 0..n { for j in i + 1..n { if bit >> i & 1 == 1 && bit >> j & 1 == 1 { tmp += b[i][j]; } } } if tmp > ans { ans = tmp; uuu = tmpu; } } println!("{}", ans); for i in 0..uuu.len() { print!("{} ", uuu[i]); } println!("") }