結果

問題 No.33 アメーバがたくさん
ユーザー masamasa
提出日時 2015-02-04 20:31:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,111 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 78,956 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:43:20
合計ジャッジ時間 1,252 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;

const long long INF = 1e18;

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++) {
		long long start = -INF;
		long long prev = it->second[0];
		ans += t;
		for (int i = 0; i < it->second.size(); i++) {
			if (start == -INF) {
				start = it->second[i];
				prev = start;
			}
			if (it->second[i] - prev > d * t * 2) {
				ans += (prev - start) / d + 1;
				ans += t * 2;
				start = -INF;
			}
			prev = it->second[i];
		}
		if (start != -INF) {
			ans += (prev - start) / d + 1;
		}
		ans += t;
	}

	cout << ans << endl;
	return 0;
}
0