結果

問題 No.1505 Zero-Product Ranges
ユーザー sigmanisigmani
提出日時 2022-03-06 13:01:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 365 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 166,428 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-20 22:22:04
合計ジャッジ時間 4,917 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A[202020];
  for(int i=1;i<=N;i++)cin>>A[i];
  long long answer=0;
  long long count=0;
  for(int i=1;i<=N;i++){
    if(A[i]==1)count++;
    else {
      answer=answer+(count*(count+1)/2);
      count=0;
    }
  }
  answer=answer+(count*(count+1)/2);
  cout<<(N*(N+1)/2)-answer;
  
}
0