結果

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

ソースコード

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);
    ll 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