結果
問題 | No.2053 12345... |
ユーザー |
|
提出日時 | 2024-03-12 12:51:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 1,425 ms |
コンパイル使用メモリ | 168,188 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-09-29 22:16:18 |
合計ジャッジ時間 | 3,491 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 31 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<int> a(n);for (auto &it : a) {cin >> it;}int cnt = 1;int curr = a[0];ll sum = 0;for (int i = 1; i < n; i++) {if (a[i] == curr) cnt++;else {// every subarray is valid add it to the sumsum += 1LL * cnt * (cnt + 1) / 2;cnt = 1;}}sum += 1LL * cnt * (cnt + 1) / 2;cout << sum << "\n";}