結果

問題 No.3068 Speedrun (Hard)
ユーザー srtry
提出日時 2025-04-29 00:21:29
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 23,892 ms
コンパイル使用メモリ 398,624 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-29 00:22:09
合計ジャッジ時間 36,785 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 13 WA * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `c`
 --> src/main.rs:6:27
  |
6 |         a:isize, b:isize, c:isize, d:isize, n:isize, 
  |                           ^ help: if this is intentional, prefix it with an underscore: `_c`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `d`
 --> src/main.rs:6:36
  |
6 |         a:isize, b:isize, c:isize, d:isize, n:isize, 
  |                                    ^ help: if this is intentional, prefix it with an underscore: `_d`

ソースコード

diff #

use proconio::input;
use std::cmp::min;

fn main() {
    input!{
        a:isize, b:isize, c:isize, d:isize, n:isize, 
        p:isize, q:isize, r:isize, s:isize, t:isize, 
    }

    let mut x_c:isize;
    let mut x_d:isize;
    let mut ans:[isize;4] = [10001, 10001, 10001, 10001];

    for x_b in 0..=(b as isize) {
        for x_a in 0..=(a as isize) {
            let tmp1:isize = n - x_a - x_b;
            let tmp2:isize = t - (p*x_a) - (q*x_b);
            
            if r==s && tmp1>r+s {
                continue;
            }

            if r!=s {
                x_d = ((tmp1*r) - tmp2) / (r-s);
                x_c = tmp1 - x_d;
            } else {
                x_c = min(r, tmp1);
                x_d = tmp1 - x_c;
            }
            

            if 0<=x_c && x_c<=r && 0<=x_d && x_d<=s {
                ans = [x_a, x_b, x_c, x_d];
                break;
            }
        }
    }
    println!("{} {} {} {}",ans[0],ans[1],ans[2],ans[3]);
}
0