結果

問題 No.33 アメーバがたくさん
ユーザー fiordfiord
提出日時 2015-07-18 23:14:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 1,527 ms
コンパイル使用メモリ 172,032 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:48:12
合計ジャッジ時間 1,871 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d,t;	cin>>n>>d>>t;
	vector<int> x(n);
	for(int i=0;i<n;i++)	cin>>x[i];
	sort(x.begin(),x.end());
	map<int,pair<int,int> > use;
	long long int ans=0;
	for(int i=0;i<n;i++){
		int mod=x[i]%d;
		if(mod<0)	mod+=d;
		int left=x[i]-d*t;	
		int right=x[i]+d*t;
		if(use.find(mod)==use.end()){
			ans+=2*t+1;
			use[mod]=make_pair(left,right);
		}
		else if(use[mod].second>=left){
			ans+=(right-use[mod].second)/d;
			use[mod].second=right;
		}
		else{
			ans+=2*t+1;
			use[mod].first=left;
			use[mod].second=right;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0