結果
| 問題 | No.1505 Zero-Product Ranges |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-18 01:29:02 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| + 828µs | |
| コード長 | 533 bytes |
| 記録 | |
| コンパイル時間 | 2,579 ms |
| コンパイル使用メモリ | 166,492 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-18 01:29:08 |
| 合計ジャッジ時間 | 3,938 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
//反算,减掉全1的数对
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
int a[200005];
cin>>n;
ll rst=n*(n+1)/2;
ll cnt1=0;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
if(a[i]==1) cnt1++;
else{
rst-=cnt1*(cnt1+1)/2;
cnt1=0;
}
}
rst-=cnt1*(cnt1+1)/2; //清除最后的连续1
cout<<rst<<endl;
return 0;
}