結果

問題 No.33 アメーバがたくさん
ユーザー fiordfiord
提出日時 2015-07-18 08:25:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 168,936 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:47:43
合計ジャッジ時間 1,765 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 1 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];
	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{
			pair<int,int> s=use.find(mod)->second;
			int sl=s.first,sr=s.second;
			if(left<sl){
				ans+=(sl-left)/d;
				use[mod].first=left;
			}
			else if(sl<right){
				ans+=(right-sr)/d;
				use[mod].second=right;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
0