結果

問題 No.1505 Zero-Product Ranges
ユーザー pengin_2000
提出日時 2021-07-25 20:55:55
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 05:18:46
合計ジャッジ時間 3,171 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	long long int ans = (n + 1) * n / 2;
	long long int cnt = 0;
	for (i = 0; i < n; i++)
	{
		if (a[i] > 0)
		{
			cnt++;
			ans -= cnt;
		}
		else
			cnt = 0;
	}
	printf("%lld\n", ans);
	return 0;
}
0