結果

問題 No.1765 While Shining
ユーザー Nzt3
提出日時 2022-09-27 17:31:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 193,844 KB
最終ジャッジ日時 2025-02-07 17:20:55
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  long long ans=0,cntE=0,cntO=0;
  for(int i=0;i<N-1;i++){
    if(A[i]){
      switch(i%2){
        case 0:ans+=++cntE,cntO=0;break;
        case 1:ans+=++cntO,cntE=0;break;
      }
    }else{
      switch(i%2){
        case 0:ans+=cntO,cntE=0;break;
        case 1:ans+=cntE,cntO=0;break;
      }
    }
  }
  cout<<ans<<'\n';
}
0