結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2024-02-14 16:32:31 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 476 bytes |
| コンパイル時間 | 11,259 ms |
| コンパイル使用メモリ | 402,804 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-09-28 18:55:56 |
| 合計ジャッジ時間 | 12,705 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 41 |
コンパイルメッセージ
warning: variable `N` should have a snake case name --> src/main.rs:4:9 | 4 | let N = input().parse::<usize>().unwrap(); | ^ help: convert the identifier to snake case: `n` | = note: `#[warn(non_snake_case)]` on by default warning: variable `A` should have a snake case name --> src/main.rs:5:9 | 5 | let A = input().split_whitespace().map(|t| t.parse::<usize>().unwrap()).collect::<Vec<_>>(); | ^ help: convert the identifier to snake case: `a`
ソースコード
use std::io::stdin;
fn main() {
let N = input().parse::<usize>().unwrap();
let A = input().split_whitespace().map(|t| t.parse::<usize>().unwrap()).collect::<Vec<_>>();
let mut x = N;
let mut c = 0;
for &a in A.iter().rev() {
if x==a {
c += 1;
x -= 1;
}
}
println!("{}", N-c);
}
fn input() -> String {
let mut buf = String::new();
stdin().read_line(&mut buf).unwrap();
buf.trim().to_string()
}
neko_the_shadow