結果
問題 | No.733 分身並列コーディング |
ユーザー | sntea |
提出日時 | 2018-09-29 17:27:07 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 168 ms / 1,500 ms |
コード長 | 3,172 bytes |
コンパイル時間 | 12,895 ms |
コンパイル使用メモリ | 396,704 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:17:41 |
合計ジャッジ時間 | 15,903 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 167 ms
5,248 KB |
testcase_04 | AC | 168 ms
5,248 KB |
testcase_05 | AC | 13 ms
5,248 KB |
testcase_06 | AC | 1 ms
5,248 KB |
testcase_07 | AC | 33 ms
5,248 KB |
testcase_08 | AC | 23 ms
5,248 KB |
testcase_09 | AC | 44 ms
5,248 KB |
testcase_10 | AC | 5 ms
5,248 KB |
testcase_11 | AC | 6 ms
5,248 KB |
testcase_12 | AC | 1 ms
5,248 KB |
testcase_13 | AC | 1 ms
5,248 KB |
testcase_14 | AC | 24 ms
5,248 KB |
testcase_15 | AC | 3 ms
5,248 KB |
testcase_16 | AC | 1 ms
5,248 KB |
testcase_17 | AC | 1 ms
5,248 KB |
testcase_18 | AC | 3 ms
5,248 KB |
testcase_19 | AC | 49 ms
5,248 KB |
testcase_20 | AC | 36 ms
5,248 KB |
testcase_21 | AC | 25 ms
5,248 KB |
testcase_22 | AC | 90 ms
5,248 KB |
testcase_23 | AC | 20 ms
5,248 KB |
testcase_24 | AC | 13 ms
5,248 KB |
testcase_25 | AC | 1 ms
5,248 KB |
testcase_26 | AC | 1 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 23 ms
5,248 KB |
testcase_29 | AC | 53 ms
5,248 KB |
testcase_30 | AC | 52 ms
5,248 KB |
testcase_31 | AC | 52 ms
5,248 KB |
testcase_32 | AC | 6 ms
5,248 KB |
testcase_33 | AC | 6 ms
5,248 KB |
testcase_34 | AC | 6 ms
5,248 KB |
testcase_35 | AC | 6 ms
5,248 KB |
testcase_36 | AC | 6 ms
5,248 KB |
testcase_37 | AC | 6 ms
5,248 KB |
testcase_38 | AC | 43 ms
5,248 KB |
testcase_39 | AC | 43 ms
5,248 KB |
testcase_40 | AC | 42 ms
5,248 KB |
testcase_41 | AC | 6 ms
5,248 KB |
testcase_42 | AC | 6 ms
5,248 KB |
testcase_43 | AC | 6 ms
5,248 KB |
testcase_44 | AC | 43 ms
5,248 KB |
testcase_45 | AC | 43 ms
5,248 KB |
testcase_46 | AC | 43 ms
5,248 KB |
testcase_47 | AC | 43 ms
5,248 KB |
testcase_48 | AC | 43 ms
5,248 KB |
コンパイルメッセージ
warning: unused macro definition: `printf` --> src/main.rs:79:18 | 79 | macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); } | ^^^^^^ | = note: `#[warn(unused_macros)]` on by default warning: unused variable: `i` --> src/main.rs:103:9 | 103 | for i in 0.. { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: variable does not need to be mutable --> src/main.rs:8:13 | 8 | let mut s = { | ----^ | | | help: remove this `mut` ... 82 | / input! { 83 | | ti: usize, 84 | | n: usize, 85 | | t: [usize; n], 86 | | } | |_____- in this macro invocation | = note: `#[warn(unused_mut)]` on by default = note: this warning originates in the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
// from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } #[allow(unused_macros)] macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } // macro_rules! debug { ($x: expr) => () } #[allow(dead_code)] fn show<T>(iter: T) -> String where T: Iterator, T::Item: std::fmt::Display { let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e)); res.pop(); res } #[allow(unused_imports)] use std::cmp::{max, min}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::collections::btree_map::Entry::{Occupied, Vacant}; #[allow(unused_imports)] use std::mem::swap; fn main() { use std::io::Write; let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); } macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); } input! { ti: usize, n: usize, t: [usize; n], } let mut ssum = vec![0; 1<<n]; for mask in 1..1<<n { for i in 0..n { if (mask>>i)&1 == 1 { ssum[mask] = ssum[mask^(1<<i)]+t[i]; break; } } } let inf = 1_000_000_000; let mut dp = vec![false; 1<<n]; dp[0] = true; let mut ans = 0; for i in 0.. { // debug!(i); ans += 1; let mut nex = vec![inf; 1<<n]; for mask in 0..1<<n { if dp[mask] { nex[mask] = 0; } for k in 0..n { if (mask>>k)&1 == 1 { nex[mask] = min(nex[mask], nex[mask^(1<<k)]+t[k]); } } } // debug!(nex); dp = nex.into_iter().map(|e| e <= ti).collect(); if dp[(1<<n)-1] { break; } } printfln!("{}", ans); }