結果

問題 No.1505 Zero-Product Ranges
ユーザー forest3
提出日時 2021-05-19 00:49:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 169,016 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 01:09:08
合計ジャッジ時間 5,145 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	long long ans = 0;
	int l = -1;
	for( int i = 0; i < N; i++ ) {
		if( A[i] == 0 ) l = i;
		if( l >= 0 ) ans += l + 1;
	}

	cout << ans << endl;
}
0