結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
penguinshunya
|
| 提出日時 | 2021-11-26 22:37:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 780 bytes |
| コンパイル時間 | 2,070 ms |
| コンパイル使用メモリ | 195,456 KB |
| 最終ジャッジ日時 | 2025-01-26 01:32:35 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 8 |
ソースコード
#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];
}
reverse(a.begin(), a.end());
int status = -1;
int ans = 0;
int acc = 0;
for (int i = 0; i < n; i++) {
if (status == -1) {
if (a[i] == 1) {
status = 0;
acc = i == 0 ? 0 : 1;
ans += acc;
}
} else if (status == 0) {
if (a[i] == 0) {
status = 1;
acc += 1;
} else {
status = 0;
acc = 1;
ans += acc;
}
} else if (status == 1) {
if (a[i] == 1) {
status = 0;
acc += 1;
ans += acc;
} else {
status = 1;
acc = 1;
}
}
}
cout << ans << endl;
return 0;
}
penguinshunya