結果
問題 |
No.3068 Speedrun (Hard)
|
ユーザー |
|
提出日時 | 2025-03-22 09:29:14 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 606 ms / 2,000 ms |
コード長 | 1,720 bytes |
コンパイル時間 | 12,805 ms |
コンパイル使用メモリ | 395,764 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-22 09:29:33 |
合計ジャッジ時間 | 18,206 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
コンパイルメッセージ
warning: value assigned to `ans` is never read --> src/main.rs:17:13 | 17 | let mut ans = (0, 0, 0, 0); | ^^^ | = help: maybe it is overwritten before being read? = note: `#[warn(unused_assignments)]` on by default warning: variable `A` should have a snake case name --> src/main.rs:6:9 | 6 | A: usize, | ^ help: convert the identifier to snake case: `a` | = note: `#[warn(non_snake_case)]` on by default warning: variable `B` should have a snake case name --> src/main.rs:7:9 | 7 | B: usize, | ^ help: convert the identifier to snake case: `b` warning: variable `C` should have a snake case name --> src/main.rs:8:9 | 8 | C: usize, | ^ help: convert the identifier to snake case (notice the capitalization): `c` warning: variable `D` should have a snake case name --> src/main.rs:9:9 | 9 | D: usize, | ^ help: convert the identifier to snake case: `d` warning: variable `P` should have a snake case name --> src/main.rs:11:9 | 11 | P: i64, | ^ help: convert the identifier to snake case: `p` warning: variable `Q` should have a snake case name --> src/main.rs:12:9 | 12 | Q: i64, | ^ help: convert the identifier to snake case: `q` warning: variable `R` should have a snake case name --> src/main.rs:13:9 | 13 | R: i64, | ^ help: convert the identifier to snake case: `r` warning: variable `S` should have a snake case name --> src/main.rs:14:9 | 14 | S: i64, | ^ help: convert the identifier to snake case (notice the capitalization): `s` warning: variable `T` should have a snake case name --> src/main.rs:15:9 | 15 | T: i64 | ^ help: convert the identifier to snake case: `t`
ソースコード
use proconio::input; use std::cmp::min; fn main(){ input!{ A: usize, B: usize, C: usize, D: usize, n: usize, P: i64, Q: i64, R: i64, S: i64, T: i64 } let mut ans = (0, 0, 0, 0); for a in 0..=A { for b in 0..=B { if a + b > n { continue; } let rem_n = n - a - b; let rem_t = T - P * a as i64 - Q * b as i64; if R == S { if rem_n as i64 * R != rem_t { continue; } if C + D < rem_n { continue; } let nc = min(C, rem_n); ans = (a, b, nc, rem_n - nc); println!("{} {} {} {}", ans.0, ans.1, ans.2, ans.3); return; } else if R < S { let diff = S - R; let num = rem_n as i64 * S - rem_t; if num % diff != 0 { continue; } let c = num / diff; let d = rem_n as i64 - c; if c < 0 || c > C as i64 || d < 0 || d > D as i64 { continue; } ans = (a, b, c as usize, d as usize); println!("{} {} {} {}", ans.0, ans.1, ans.2, ans.3); return; } else { let diff = R - S; let num = rem_t - rem_n as i64 * S; if num % diff != 0 { continue; } let c = num / diff; let d = rem_n as i64 - c; if c < 0 || c > C as i64 || d < 0 || d > D as i64 { continue; } ans = (a, b, c as usize, d as usize); println!("{} {} {} {}", ans.0, ans.1, ans.2, ans.3); return; } } } }