結果
問題 | No.1765 While Shining |
ユーザー |
![]() |
提出日時 | 2021-11-26 22:38:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 845 bytes |
コンパイル時間 | 2,077 ms |
コンパイル使用メモリ | 195,268 KB |
最終ジャッジ日時 | 2025-01-26 01:33:37 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 1 |
ソースコード
#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 { status = 1; acc = i == 0 ? 0 : 1; } } 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; }