結果

問題 No.1268 Fruit Rush 2
ユーザー 沙耶花沙耶花
提出日時 2020-10-23 22:42:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 732 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 208,756 KB
実行使用メモリ 17,736 KB
最終ジャッジ日時 2023-09-28 16:53:41
合計ジャッジ時間 6,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 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 1 ms
4,380 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 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 118 ms
17,440 KB
testcase_27 AC 120 ms
17,460 KB
testcase_28 AC 118 ms
17,196 KB
testcase_29 AC 117 ms
17,156 KB
testcase_30 AC 118 ms
17,592 KB
testcase_31 AC 77 ms
7,780 KB
testcase_32 AC 78 ms
7,772 KB
testcase_33 AC 135 ms
7,728 KB
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000003

int main(){	
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	rep(i,N){
		cin>>A[i];
	}
	
	sort(A.begin(),A.end());
	
	long long ans = N;
	vector<vector<long long>> X;
	rep(i,N){
		if(i==0)X.push_back(vector<long long>(1,A[i]));
		else{
			if(X.back().back()+1==A[i])X.back().push_back(A[i]);
			else X.push_back(vector<long long>(1,A[i]));
		}
	}
	
	vector<long long> dp(N+100,0);
	
	for(int i=2;i<dp.size();i++){
		dp[i] += dp[i-1];
		dp[i] += (i-2)/2;
	}
	
	rep(i,X.size()){
		if(X[i].size()==0)continue;
		ans += X[i].size()-1;
		ans += dp[X[i].size()];
	}
	
	cout<<ans<<endl;
	
    return 0;
}
0