結果

問題 No.33 アメーバがたくさん
ユーザー fiordfiord
提出日時 2015-07-18 23:51:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 560 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 173,828 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:47:46
合計ジャッジ時間 2,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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