結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
|
提出日時 | 2021-05-17 17:05:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 1,572 ms |
コンパイル使用メモリ | 167,928 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 18:27:55 |
合計ジャッジ時間 | 4,964 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long longint main(){ll n;cin>>n;vector<int>a(n);for(int i=0;i<n;i++){cin>>a[i];}ll ans=0,res=(n*(n+1))/2;for(int i=0;i<n;i++){if(a[i]==1){ll j=i;ll c=0;while(j<n && a[j]==1){c++;j++;}ans+=(c*(c+1))/2;i=j;}}cout<<res-ans;return 0;}