結果

問題 No.1765 While Shining
ユーザー kotatsugamekotatsugame
提出日時 2021-11-26 22:25:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 65,168 KB
実行使用メモリ 5,076 KB
最終ジャッジ日時 2023-09-12 05:07:36
合計ジャッジ時間 2,012 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 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,376 KB
testcase_09 AC 21 ms
4,628 KB
testcase_10 AC 29 ms
4,784 KB
testcase_11 AC 26 ms
4,660 KB
testcase_12 AC 28 ms
4,944 KB
testcase_13 AC 25 ms
4,636 KB
testcase_14 AC 31 ms
5,076 KB
testcase_15 AC 32 ms
4,896 KB
testcase_16 AC 32 ms
4,940 KB
testcase_17 AC 31 ms
4,912 KB
testcase_18 AC 31 ms
4,900 KB
testcase_19 AC 31 ms
4,944 KB
testcase_20 AC 31 ms
4,884 KB
testcase_21 AC 31 ms
4,880 KB
testcase_22 AC 31 ms
4,892 KB
testcase_23 AC 31 ms
4,888 KB
testcase_24 AC 31 ms
4,892 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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(i+2==N||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