結果

問題 No.1765 While Shining
ユーザー startcppstartcpp
提出日時 2021-11-26 22:39:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 373 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 63,640 KB
実行使用メモリ 5,220 KB
最終ジャッジ日時 2023-09-12 05:16:04
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 30 ms
4,976 KB
testcase_11 AC 26 ms
4,620 KB
testcase_12 AC 29 ms
4,720 KB
testcase_13 AC 26 ms
4,768 KB
testcase_14 AC 32 ms
4,896 KB
testcase_15 AC 32 ms
5,028 KB
testcase_16 AC 32 ms
4,900 KB
testcase_17 AC 32 ms
4,892 KB
testcase_18 AC 32 ms
4,892 KB
testcase_19 AC 32 ms
4,952 KB
testcase_20 AC 32 ms
4,900 KB
testcase_21 AC 32 ms
4,968 KB
testcase_22 AC 32 ms
5,220 KB
testcase_23 AC 32 ms
4,936 KB
testcase_24 AC 32 ms
4,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0