結果

問題 No.1268 Fruit Rush 2
ユーザー furafura
提出日時 2020-10-23 22:26:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 2,591 ms
コンパイル使用メモリ 205,076 KB
実行使用メモリ 20,488 KB
最終ジャッジ日時 2023-09-28 16:25:30
合計ジャッジ時間 6,172 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 86 ms
14,128 KB
testcase_17 AC 78 ms
12,976 KB
testcase_18 AC 82 ms
13,892 KB
testcase_19 AC 80 ms
14,160 KB
testcase_20 AC 80 ms
13,472 KB
testcase_21 AC 79 ms
13,948 KB
testcase_22 AC 86 ms
13,428 KB
testcase_23 AC 84 ms
13,068 KB
testcase_24 AC 81 ms
13,604 KB
testcase_25 AC 80 ms
13,364 KB
testcase_26 AC 151 ms
20,372 KB
testcase_27 AC 150 ms
20,380 KB
testcase_28 AC 150 ms
20,436 KB
testcase_29 AC 150 ms
20,248 KB
testcase_30 AC 149 ms
20,488 KB
testcase_31 AC 91 ms
14,156 KB
testcase_32 AC 91 ms
13,960 KB
testcase_33 AC 93 ms
14,032 KB
testcase_34 AC 95 ms
15,548 KB
testcase_35 AC 112 ms
15,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	sort(a.begin(),a.end());

	vector<lint> X;
	rep(i,n){
		for(int d=-2;d<=2;d++){
			if(a[i]+d>0) X.emplace_back(a[i]+d);
		}
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	int m=X.size();

	vector<lint> dp(m);
	rep(i,m){
		if(binary_search(a.begin(),a.end(),X[i])){
			dp[i]+=1;
		}
		if(binary_search(a.begin(),a.end(),X[i]-1)){
			int idx=lower_bound(X.begin(),X.end(),X[i]-2)-X.begin();
			if(idx>=0 && X[idx]==X[i]-2){
				dp[i]+=dp[idx];
			}
		}
	}
	printf("%lld\n",accumulate(dp.begin(),dp.end(),0LL));

	return 0;
}
0