結果

問題 No.1765 While Shining
ユーザー HaaHaa
提出日時 2021-11-26 22:31:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 167,224 KB
実行使用メモリ 4,852 KB
最終ジャッジ日時 2023-09-12 05:10:51
合計ジャッジ時間 3,177 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 30 ms
4,396 KB
testcase_11 AC 27 ms
4,376 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 26 ms
4,408 KB
testcase_14 AC 32 ms
4,604 KB
testcase_15 AC 32 ms
4,624 KB
testcase_16 AC 32 ms
4,676 KB
testcase_17 AC 32 ms
4,684 KB
testcase_18 AC 32 ms
4,664 KB
testcase_19 AC 32 ms
4,600 KB
testcase_20 AC 32 ms
4,616 KB
testcase_21 AC 32 ms
4,568 KB
testcase_22 AC 32 ms
4,612 KB
testcase_23 AC 33 ms
4,624 KB
testcase_24 AC 33 ms
4,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

int main(){
    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    REP(i,n){
        if(i%2==1)
            a[i]=!a[i];
    }
    int x=0;
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        if(i<n-1){
            if(a[i]==a[i+1])
                x++;
            else
                x=1;
        }
        if(i%2!=a[i])
            ans+=x;
    }
    cout << ans << endl;
    return 0;
}
0