結果

問題 No.1765 While Shining
ユーザー kotatsugamekotatsugame
提出日時 2021-11-26 22:24:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 299 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 64,328 KB
実行使用メモリ 5,180 KB
最終ジャッジ日時 2023-09-12 05:06:55
合計ジャッジ時間 2,175 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 21 ms
4,384 KB
testcase_10 AC 30 ms
4,792 KB
testcase_11 AC 26 ms
4,620 KB
testcase_12 AC 28 ms
4,716 KB
testcase_13 AC 25 ms
4,612 KB
testcase_14 AC 31 ms
4,948 KB
testcase_15 AC 31 ms
4,964 KB
testcase_16 AC 31 ms
4,956 KB
testcase_17 AC 32 ms
5,024 KB
testcase_18 AC 31 ms
4,916 KB
testcase_19 AC 31 ms
4,904 KB
testcase_20 AC 31 ms
4,892 KB
testcase_21 AC 32 ms
5,180 KB
testcase_22 WA -
testcase_23 AC 32 ms
5,044 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
int A[2<<17];
int cnt[2<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	long ans=0;
	for(int i=N;i--;)
	{
		if(i+1<N&&A[i]==1)
		{
			if(A[i+1]==1)cnt[i]=1;
			else cnt[i]=cnt[i+2]+2;
		}
		else cnt[i]=0;
		ans+=cnt[i];
	}
	cout<<ans<<endl;
}
0