結果
| 問題 | No.2053 12345... |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-09-06 05:12:57 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 722 bytes |
| 記録 | |
| コンパイル時間 | 7,427 ms |
| コンパイル使用メモリ | 188,244 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-15 11:42:45 |
| 合計ジャッジ時間 | 4,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)]` (part of `#[warn(nonstandard_style)]`) 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