結果
| 問題 |
No.3065 Speedrun (Normal)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-22 07:43:15 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 3,096 bytes |
| コンパイル時間 | 13,985 ms |
| コンパイル使用メモリ | 394,184 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2025-03-22 07:43:31 |
| 合計ジャッジ時間 | 15,314 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
fn main() {
// A1つをP分、
// B1つをQ分、
// C1つをR分、
// D1つをS分
// かかる時間が少ないものから貪欲にやる
let abcd : Vec<usize> = read_numbers_vec(4);
let pqrst : Vec<usize> = read_numbers_vec(5);
// 1問あたりの時間と問題数をペアにする(昇順)
let mut qt_pair = Vec::new();
for i in 0..4 {
qt_pair.push((pqrst[i], abcd[i]));
}
qt_pair.sort();
let mut cnt = 0;
let mut rest_time = pqrst[4];
for i in 0..4 {
// 問題iセットのレベルを全て解ける
if qt_pair[i].0 * qt_pair[i].1 <= rest_time {
cnt += qt_pair[i].1;
rest_time -= qt_pair[i].0 * qt_pair[i].1;
}
// 解けない問題が出てくる
else {
let enabled_cnt = rest_time / qt_pair[i].0;
cnt += enabled_cnt;
rest_time -= qt_pair[i].0 * enabled_cnt;
}
}
println!("{}", cnt);
}
// ---------- start input macro ----------
// const MOD17: usize = 1000000007;
// const MOD93: usize = 998244353;
// const INF: usize = 1 << 60;
// let dx = vec![!0, 0, 1, 0]; // 上左下右
// let dy = vec![0, !0, 0, 1]; // 上左下右
// let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右
#[allow(unused)]
use std::{
io, io::stderr, io::stdin, io::BufRead, io::Write, str::FromStr,
mem::swap,
cmp::min, cmp::max,
cmp::Reverse,
collections::HashSet, collections::BTreeSet,
collections::HashMap, collections::BTreeMap,
collections::BinaryHeap,
collections::VecDeque,
};
// usizeで受け取り
#[allow(unused)]
fn read_usize() -> usize {
let mut input = String::new();
io::stdout().flush().unwrap(); // 出力バッファをフラッシュ
io::stdin().read_line(&mut input).unwrap();
input.trim().parse().unwrap()
}
// 数値型を配列で受け取り
#[allow(unused)]
fn read_numbers_vec<T>(n: usize) -> Vec<T>
where
T: FromStr,
<T as FromStr>::Err: std::fmt::Debug,
{
let mut input = String::new();
io::stdout().flush().unwrap();
io::stdin().read_line(&mut input).unwrap();
input.trim()
.split_whitespace() // 空白区切りで分割
.take(n) // 指定された個数分だけ取り出す
.map(|s| s.parse().unwrap()) // 各値をTに変換
.collect() // ベクターとして収集
}
// char型配列で受け取り
#[allow(unused)]
fn read_char_array() -> Vec<char> {
let mut input = String::new();
io::stdout().flush().unwrap();
io::stdin().read_line(&mut input).unwrap();
input.trim().chars().collect()
}
// 文字列型で受け取り
#[allow(unused)]
fn read_string() -> String {
let mut input = String::new();
io::stdout().flush().unwrap();
io::stdin().read_line(&mut input).unwrap();
input.trim().to_string()
}
// 配列のスペース区切り出力
#[allow(unused)]
fn vec_print<T: std::fmt::Display>(vec: &Vec<T>) {
let sz = vec.len();
for i in 0..sz-1 {
print!("{} ", vec[i]);
}
println!("{}", vec[sz-1]);
}
// ---------- end input macro ----------