結果
| 問題 |
No.2053 12345...
|
| コンテスト | |
| ユーザー |
mmn15277198
|
| 提出日時 | 2022-08-21 22:14:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 519 bytes |
| コンパイル時間 | 1,699 ms |
| コンパイル使用メモリ | 175,556 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 06:25:27 |
| 合計ジャッジ時間 | 4,079 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 21 WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int cnt = 1;
map<int, int> mp;
for (int i = 0; i < n - 1; i++) {
if (a[i] - a[i + 1] == -1) {
cnt++;
} else {
mp[cnt]++;
cnt = 1;
}
}
if (cnt > 1) mp[cnt]++;
long long ans = 0;
for (auto i : mp) {
if (i.first <= 1) continue;
ans += (i.first) * (i.first - 1) / 2 * i.second;
}
cout << ans << endl;
return 0;
}
mmn15277198