結果
| 問題 | 
                            No.33 アメーバがたくさん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-02-04 20:47:00 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,392 bytes | 
| コンパイル時間 | 800 ms | 
| コンパイル使用メモリ | 79,564 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-24 10:01:15 | 
| 合計ジャッジ時間 | 1,278 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
const long long INF = 1e18;
template <class T>
void show(T &a, string sep = " ") {
	for (auto it = a.begin(); it != a.end(); it++) {
		cout << *it << sep;
	}
	cout << endl;
}
int main() {
	long long n, d, t;
	cin >> n >> d >> t;
	map<int,  vector<long long> > aaa;
	vector<long long> x(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < n; i++) {
		int idx = (x[i] + (int)1e9) % d;
		auto it = aaa.find(idx);
		if (it == aaa.end()) {
			aaa[idx] = vector<long long>(1, x[i]);
		} else {
			aaa[idx].push_back(x[i]);
		}
	}
	long long ans = 0;
	for (auto it = aaa.begin(); it != aaa.end(); it++) {
		// printf("%2d: ", it->first);
		// show(it->second);
		long long start = it->second[0];
		long long prev = start;
		ans += t;
		for (int i = 0; i < it->second.size(); i++) {
			// printf("%d now %lld prev %lld, start %lld,  ", i, it->second[i], prev, start);
			if (it->second[i] - prev > d * t * 2) {
				ans += (prev - start) / d + 1 + t + t;
				start = it->second[i];
			}
			// printf("ans %lld\n", ans);
			prev = it->second[i];
		}
		if (start != -INF) {
			ans += (prev - start) / d + 1;
		}
		ans += t;
		// printf("ans %lld\n", ans);
	}
	cout << ans << endl;
	return 0;
}