結果

問題 No.1765 While Shining
ユーザー se1ka2se1ka2
提出日時 2021-11-26 22:27:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 568 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 64,836 KB
実行使用メモリ 5,984 KB
最終ジャッジ日時 2023-09-12 05:08:36
合計ジャッジ時間 2,017 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 21 ms
4,824 KB
testcase_10 AC 29 ms
5,564 KB
testcase_11 AC 27 ms
5,240 KB
testcase_12 AC 27 ms
5,628 KB
testcase_13 AC 26 ms
5,512 KB
testcase_14 AC 31 ms
5,708 KB
testcase_15 AC 32 ms
5,780 KB
testcase_16 AC 31 ms
5,652 KB
testcase_17 AC 31 ms
5,720 KB
testcase_18 AC 32 ms
5,712 KB
testcase_19 AC 32 ms
5,672 KB
testcase_20 AC 32 ms
5,716 KB
testcase_21 AC 32 ms
5,720 KB
testcase_22 WA -
testcase_23 AC 32 ms
5,772 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0