結果

問題 No.1505 Zero-Product Ranges
ユーザー shu8Cream
提出日時 2021-05-15 14:12:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 1,947 ms
コンパイル使用メモリ 194,452 KB
最終ジャッジ日時 2025-01-21 12:57:38
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    author:  shu8Cream
*    created: 15.05.2021 13:04:09
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vi a(n); rep(i,n) cin >> a[i];
    ll ans = 0, cnt = 0;
    rep(i,n){
        if(a[i]) cnt++;
        else{
            ans += (cnt+1)*cnt/2;
            cnt = 0;
        }
    }
    ans += (cnt+1)*cnt/2;
    cout << (n+1)*n/2-ans << endl;
}
0