結果

問題 No.33 アメーバがたくさん
ユーザー HaarHaar
提出日時 2016-05-31 15:34:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,180 bytes
コンパイル時間 2,316 ms
コンパイル使用メモリ 173,188 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 20:18:16
合計ジャッジ時間 2,100 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 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define PF push_front
#define ALL(x) (x).begin(), (x).end()
#define C complex
#define CI complex< int >
#define CD complex< double >
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, d, t, x;
	long int c = 0;
	map< int, vector< int > > mp;
	
	cin >> n >> d >> t;
	REP(i, n){
		cin >> x;
		
		int mod;
		if(x>=0 || x % d == 0) mod = x % d;
		else mod = d - ((-x) % d);
		
		if(mp.find(mod) != mp.end()){
			mp[mod].PB(x);
		}else{
			vector< int > temp;
			mp[mod] = temp;
			mp[mod].PB(x);
		}
	}
	
	for(map< int, vector< int > >::iterator it = mp.begin(); it != mp.end(); ++it){
		vector< int > v = it->second;
		
		REP(i, v.size()) v[i] /= d;
		
		sort(ALL(v));
		
		int cnt = t * 2 + 1;
		FOR(i, 1, v.size()){
			
			if(v[i-1] + t < v[i] - t){
				cnt += 2 * t + 1;
			}else{
				cnt += (v[i] - v[i-1]);
			}
		}
		c += cnt;
		
	}
	
	cout << c << endl;
	
	return 0;
}
0