結果
| 問題 |
No.1505 Zero-Product Ranges
|
| コンテスト | |
| ユーザー |
shisidor
|
| 提出日時 | 2023-04-01 17:22:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 423 bytes |
| コンパイル時間 | 663 ms |
| コンパイル使用メモリ | 63,896 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 11:08:04 |
| 合計ジャッジ時間 | 4,315 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
long long res = 0, count = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
if (a == 1) count++;
if (a == 0 || i == n - 1) {
res += (long long)count * (count + 1) / 2;
count = 0;
}
}
res = (long long)n * (n + 1) / 2 - res;
cout << res << endl;
return 0;
}
shisidor