結果
| 問題 |
No.35 タイパー高橋
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-02 16:34:43 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,722 bytes |
| コンパイル時間 | 16,735 ms |
| コンパイル使用メモリ | 387,372 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 12:26:50 |
| 合計ジャッジ時間 | 17,777 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
use std::io::stdin;
/// 入力データ
struct InputData {
/// ゲーム数
_count: i32,
/// 問題
questions: Vec<Question>,
}
/// 問題
struct Question {
/// 制限時間
limit: i32,
/// 入力すべき文字列
type_str: String,
}
/// エントリポイント
fn main() {
let input = input_data();
let result = typing(input);
println!("{} {}", result.0, result.1);
}
/// タイピングゲームの結果を返します。
/// # 戻り値
/// 以下の値を格納したタプル
/// 0: 正しくタイプできる文字数
/// 1: タイプできずに逃してしまう文字数
fn typing(input: InputData) -> (i32, i32) {
let mut ok_type = 0;
let mut ng_type = 0;
for qu in input.questions {
let type_num = 12 * qu.limit / 1000;
let str_len = qu.type_str.len() as i32;
if type_num >= str_len {
ok_type += str_len;
} else {
ok_type += type_num;
ng_type += str_len - type_num;
}
}
(ok_type, ng_type)
}
/// 標準入力から文字列を取得します。
fn input_data() -> InputData {
// 1行目
let mut count = String::new();
stdin().read_line(&mut count).unwrap();
let count: i32 = count.trim().parse().unwrap();
// 2行目以降
let mut questions = Vec::new();
for _i in 0..count {
let mut q = String::new();
stdin().read_line(&mut q).unwrap();
let sp: Vec<&str> = q.trim().split_whitespace().collect();
questions.push(Question {
limit: sp[0].trim().parse().unwrap(),
type_str: sp[1].to_string(),
});
}
InputData {
_count: count,
questions,
}
}