結果
問題 | No.1765 While Shining |
ユーザー |
![]() |
提出日時 | 2021-11-26 22:27:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 568 bytes |
コンパイル時間 | 491 ms |
コンパイル使用メモリ | 63,872 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-06-29 18:10:01 |
合計ジャッジ時間 | 1,783 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 3 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; int main() { int n; cin >> n; int a[200005]; for(int i = 0; i < n; i++) cin >> a[i]; a[n] = 0; ll s[200005]; s[n - 1] = 0; for(int i = n - 2; i >= 0; i--){ if(a[i] == 0) s[i] = 0; if(a[i] == 1){ if(a[i + 1] == 0){ if(a[i + 2] == 1) s[i] = s[i + 2] + 2; else s[i] = 2; } else s[i] = 1; } } ll ans = 0; for(int i = 0; i < n; i++) ans += s[i]; cout << ans << endl; }