結果
| 問題 |
No.2014 Eggs Hatching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-07 21:10:48 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,641 bytes |
| コンパイル時間 | 13,225 ms |
| コンパイル使用メモリ | 396,516 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 05:14:52 |
| 合計ジャッジ時間 | 14,384 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#[allow(dead_code)]
pub mod nayuta {
use std::{error::Error, str::FromStr};
use std::{io, result};
pub type Result<T> = result::Result<T, Box<dyn Error>>;
/// データを1行分、単一の文字列として読み込む
///
/// 末尾の改行は取り除かれます。たぶん空白も
pub fn input_string() -> Result<String> {
let mut s: String = String::new();
io::stdin().read_line(&mut s)?;
Ok(s.trim().into())
}
/// データを1行分、1つのデータとして読み込む
pub fn input_single<T>() -> Result<T>
where
T: FromStr,
<T as FromStr>::Err: 'static + Error,
{
let s: String = input_string()?;
Ok(s.parse::<T>()?)
}
/// データを1行分、単一データ型のリスト (Vec) として読み込む
pub fn input_vector<T>() -> Result<Vec<T>>
where
T: FromStr,
<T as FromStr>::Err: 'static + Error,
{
let s: String = input_string()?;
let v: Vec<T> = s
.split_ascii_whitespace()
.map(|x: &str| -> Result<T> { x.parse::<T>().map_err(|e| e.into()) })
.collect::<Result<_>>()?;
Ok(v)
}
/// データを1行分、空白区切りの2要素として読み込む
pub fn input_two_tuple<T>() -> Result<(T, T)>
where
T: FromStr + Copy,
<T as FromStr>::Err: 'static + Error,
{
let v: Vec<T> = input_vector()?;
Ok((v[0], v[1]))
}
}
fn main() -> nayuta::Result<()> {
let a = nayuta::input_vector::<usize>()?;
println!("{}", a.iter().min().unwrap());
Ok(())
}