結果
| 問題 |
No.1505 Zero-Product Ranges
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-14 22:06:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 313 bytes |
| コンパイル時間 | 487 ms |
| コンパイル使用メモリ | 64,296 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-02 01:18:49 |
| 合計ジャッジ時間 | 2,804 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}