結果
問題 | No.2099 [Cherry Alpha B] Time Machine |
ユーザー | phspls |
提出日時 | 2022-10-15 00:18:39 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,936 bytes |
コンパイル時間 | 18,765 ms |
コンパイル使用メモリ | 378,536 KB |
実行使用メモリ | 315,912 KB |
最終ジャッジ日時 | 2024-06-26 18:21:47 |
合計ジャッジ時間 | 41,433 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
158,264 KB |
testcase_01 | AC | 44 ms
158,080 KB |
testcase_02 | AC | 44 ms
158,080 KB |
testcase_03 | AC | 45 ms
158,044 KB |
testcase_04 | WA | - |
testcase_05 | AC | 1,841 ms
314,368 KB |
testcase_06 | AC | 202 ms
157,956 KB |
testcase_07 | AC | 43 ms
158,208 KB |
testcase_08 | AC | 1,326 ms
166,488 KB |
testcase_09 | AC | 1,120 ms
184,704 KB |
testcase_10 | AC | 901 ms
159,616 KB |
testcase_11 | AC | 233 ms
159,232 KB |
testcase_12 | AC | 1,034 ms
171,648 KB |
testcase_13 | AC | 43 ms
158,080 KB |
testcase_14 | WA | - |
testcase_15 | AC | 1,796 ms
314,368 KB |
testcase_16 | AC | 199 ms
158,080 KB |
testcase_17 | AC | 44 ms
158,084 KB |
testcase_18 | AC | 43 ms
158,080 KB |
testcase_19 | AC | 43 ms
158,080 KB |
testcase_20 | AC | 44 ms
158,196 KB |
testcase_21 | AC | 44 ms
158,080 KB |
testcase_22 | AC | 803 ms
166,144 KB |
testcase_23 | AC | 442 ms
195,328 KB |
testcase_24 | AC | 44 ms
158,080 KB |
testcase_25 | AC | 44 ms
158,080 KB |
testcase_26 | AC | 44 ms
158,048 KB |
testcase_27 | AC | 479 ms
200,320 KB |
testcase_28 | AC | 43 ms
158,080 KB |
testcase_29 | WA | - |
testcase_30 | AC | 1,800 ms
314,368 KB |
testcase_31 | AC | 203 ms
158,100 KB |
testcase_32 | AC | 43 ms
158,144 KB |
testcase_33 | AC | 44 ms
158,080 KB |
testcase_34 | WA | - |
testcase_35 | AC | 1,796 ms
315,512 KB |
testcase_36 | AC | 206 ms
158,196 KB |
testcase_37 | AC | 44 ms
158,124 KB |
testcase_38 | AC | 45 ms
158,196 KB |
testcase_39 | AC | 44 ms
158,264 KB |
testcase_40 | WA | - |
testcase_41 | AC | 44 ms
158,368 KB |
testcase_42 | AC | 44 ms
158,100 KB |
testcase_43 | AC | 132 ms
167,600 KB |
testcase_44 | AC | 44 ms
158,092 KB |
testcase_45 | AC | 45 ms
158,260 KB |
testcase_46 | AC | 757 ms
198,312 KB |
testcase_47 | AC | 43 ms
157,952 KB |
testcase_48 | AC | 43 ms
158,100 KB |
testcase_49 | WA | - |
testcase_50 | AC | 1,784 ms
315,912 KB |
testcase_51 | AC | 199 ms
158,144 KB |
testcase_52 | AC | 43 ms
158,204 KB |
testcase_53 | WA | - |
testcase_54 | AC | 45 ms
158,240 KB |
testcase_55 | WA | - |
testcase_56 | AC | 45 ms
158,156 KB |
testcase_57 | AC | 45 ms
158,048 KB |
testcase_58 | AC | 43 ms
158,100 KB |
testcase_59 | AC | 45 ms
158,260 KB |
testcase_60 | AC | 42 ms
158,184 KB |
testcase_61 | AC | 44 ms
158,240 KB |
testcase_62 | AC | 45 ms
158,256 KB |
testcase_63 | AC | 46 ms
158,160 KB |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | AC | 44 ms
158,100 KB |
testcase_69 | AC | 43 ms
158,200 KB |
testcase_70 | AC | 43 ms
158,072 KB |
testcase_71 | WA | - |
ソースコード
use std::{collections::BinaryHeap, cmp::Reverse}; const INF: usize = 1usize << 60; const OFFSET: usize = 10000001; fn main() { let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: isize = t.trim().parse().unwrap(); let mut xa = String::new(); std::io::stdin().read_line(&mut xa).ok(); let xa: Vec<usize> = xa.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let x = xa[0]; let a = xa[1]; let mut yb = String::new(); std::io::stdin().read_line(&mut yb).ok(); let yb: Vec<usize> = yb.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let y = yb[0]; let b = yb[1]; let (t, start_cost) = if t < 0 { let temp = t.abs() as usize / b + if t / b as isize == 0 { 0 } else { 1 }; let s = (b * temp) as isize + t; (s, temp * y) } else { let temp = t as usize / a; let s = t - (a * temp) as isize; (s, temp * x) }; let t = (t + OFFSET as isize) as usize; let goal = t as usize; let mut checked = vec![INF; OFFSET*2+1]; checked[OFFSET] = start_cost; let mut pque = BinaryHeap::new(); pque.push((Reverse(start_cost), OFFSET)); while let Some((Reverse(cost), pos)) = pque.pop() { if checked[goal] <= cost { break; } if checked[pos] < cost { continue; } if pos+1 < checked.len() && pos+1 <= goal && checked[pos+1] > cost + 1 { pque.push((Reverse(cost+1), pos+1)); checked[pos+1] = cost+1; } if pos+a < checked.len() && pos < goal && checked[pos+a] > cost + x { pque.push((Reverse(cost+x), pos+a)); checked[pos+a] = cost+x; } if pos >= b && pos > goal && checked[pos-b] > cost + y { pque.push((Reverse(cost+y), pos-b)); checked[pos-b] = cost+y; } } println!("{}", checked[goal]); }