結果

問題 No.1268 Fruit Rush 2
ユーザー kotatsugamekotatsugame
提出日時 2020-10-24 01:55:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 70,672 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2023-09-28 19:59:49
合計ジャッジ時間 3,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 56 ms
5,476 KB
testcase_17 AC 49 ms
5,164 KB
testcase_18 AC 51 ms
5,052 KB
testcase_19 AC 51 ms
5,176 KB
testcase_20 AC 51 ms
4,940 KB
testcase_21 AC 49 ms
4,908 KB
testcase_22 AC 57 ms
5,196 KB
testcase_23 AC 56 ms
5,372 KB
testcase_24 AC 51 ms
5,168 KB
testcase_25 AC 50 ms
4,968 KB
testcase_26 AC 95 ms
5,748 KB
testcase_27 AC 95 ms
5,832 KB
testcase_28 AC 95 ms
5,696 KB
testcase_29 AC 95 ms
5,696 KB
testcase_30 AC 95 ms
5,788 KB
testcase_31 AC 72 ms
6,016 KB
testcase_32 AC 73 ms
5,832 KB
testcase_33 AC 127 ms
5,788 KB
testcase_34 AC 61 ms
5,748 KB
testcase_35 AC 128 ms
5,768 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

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