結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2021-11-26 22:39:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 373 bytes |
| コンパイル時間 | 480 ms |
| コンパイル使用メモリ | 63,488 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-29 18:16:22 |
| 合計ジャッジ時間 | 1,587 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#define int long long
using namespace std;
int n;
int a[200000];
signed main() {
int i;
cin >> n;
for (i = 0; i < n; i++) cin >> a[i];
int len = 0;
int ans = 0;
for (i = n - 2; i >= 0; i--) {
if (len == 0 || a[i] != a[i + 1]) {
len++;
}
else {
len = 1;
}
if (a[i] == 1) { ans += len; }
}
cout << ans << endl;
return 0;
}
startcpp