結果
| 問題 |
No.2053 12345...
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-09-06 05:12:57 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 722 bytes |
| コンパイル時間 | 12,132 ms |
| コンパイル使用メモリ | 401,568 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 06:24:39 |
| 合計ジャッジ時間 | 13,986 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
コンパイルメッセージ
warning: variable `A` should have a snake case name
--> src/main.rs:8:9
|
8 | let A: Vec<i64> = {
| ^ help: convert the identifier to snake case: `a`
|
= note: `#[warn(non_snake_case)]` on by default
ソースコード
fn main() {
let n: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
};
let A: Vec<i64> = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.split_whitespace()
.map(|x| x.parse().unwrap())
.collect()
};
let mut ans:i64 = 0;
let mut score:i64=1;
for i in 1..n{
if A[i]==A[i-1]+1{
score+=1;
}
else if score>1{
ans+=score*(score-1)/2;
score=1;
}
}
if score>1{
ans+=score*(score-1)/2;
}
println!("{}",ans);
}
titia