結果

問題 No.771 しおり
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2018-12-19 12:46:27
言語 Rust
(1.72.1)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 151,868 KB
実行使用メモリ 20,432 KB
最終ジャッジ日時 2023-09-29 12:48:02
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
20,380 KB
testcase_01 AC 18 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 85 ms
10,664 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 19 ms
4,380 KB
testcase_28 AC 39 ms
6,180 KB
testcase_29 AC 19 ms
4,376 KB
testcase_30 AC 177 ms
20,432 KB
testcase_31 AC 178 ms
20,340 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 178 ms
20,432 KB
testcase_34 AC 177 ms
20,380 KB
testcase_35 AC 5 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 5 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 84 ms
10,612 KB
testcase_41 AC 178 ms
20,412 KB
testcase_42 AC 177 ms
20,372 KB
testcase_43 AC 19 ms
4,380 KB
testcase_44 AC 179 ms
20,416 KB
testcase_45 AC 179 ms
20,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self,Read};

fn main(){

  let inf = 100_000;
  let mut buf = String::new();
  io::stdin().read_to_string(&mut buf).unwrap();
  let mut lines = buf.lines();
  
  let n: usize = lines.next().unwrap().parse().unwrap();
  let s: usize = 1 << n;
  
  let book:Vec<(i32,i32)> = lines.by_ref().take(n).map(|line| {
      let v:Vec<i32> = line.split_whitespace().map(|x| x.parse().unwrap()).collect();
      (v[0], v[1])
    }).collect();
  
  let mut dp:Vec<Vec<i32>> = (0..n).map(|_i| vec![inf; s] ).collect();
  for i in 0 .. n {
    dp[i][1 << i] = 0;
  }
  
  for state in 1 .. s {
    let (used, unused): (Vec<usize>, Vec<usize>) = (0 .. n).partition(|x| state  & (1_usize << x) > 0 );
    for &j in unused.iter() {
      dp[j][ state | (1_usize << j)] = used.iter()
        .fold(inf,|m, &i| std::cmp::min(m, std::cmp::max(dp[i][state], book[i].1 - book[i].0 + book[j].0)));
    }
  }
  
  println!("{}", (0..n).map(|i| dp[i][s - 1] ).min().unwrap());
}






0