結果
| 問題 | No.1505 Zero-Product Ranges |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-14 22:06:18 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 21 ms / 2,000 ms |
| + 345µs | |
| コード長 | 313 bytes |
| 記録 | |
| コンパイル時間 | 304 ms |
| コンパイル使用メモリ | 72,884 KB |
| 実行使用メモリ | 10,028 KB |
| 最終ジャッジ日時 | 2026-09-08 11:06:55 |
| 合計ジャッジ時間 | 3,528 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int N;
int A[2<<17];
main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
long ans=(long)N*(N+1)/2;
for(int i=0;i<N;)
{
if(A[i]==0)
{
i++;
continue;
}
int r=i;
while(r<N&&A[r]==1)r++;
int len=r-i;
i=r;
ans-=(long)len*(len+1)/2;
}
cout<<ans<<endl;
}