結果

問題 No.33 アメーバがたくさん
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-15 20:36:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 832 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 167,024 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:46:12
合計ジャッジ時間 1,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;


int main() {
	int N;
	long long D, T;
	cin >> N >> D >> T;
	vector<long long> X(N);
	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
		X[i] += (long long)1e9;
	}
	sort(X.begin(), X.end());
	vector<int> check(N, 0);
	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (check[i]) continue;
		vector<int> v;
		for (int j = i; j < N; j++)
		{
			if (X[j] % D == X[i] % D){
				v.push_back(X[j]);
				check[j] = 1;
			}
		}
		long long low = v[0] - T * D;
		long long high = v[0] + T * D;
		for (int j = 1; j < v.size(); j++)
		{
			long long nlow = v[j] - T * D;
			long long nhigh = v[j] + T * D;
			if (nlow > high){
				ans += (high - low) / D + 1;
				low = nlow;
				high = nhigh;
			}
			else{
				high = nhigh;
			}
		}
		ans += (high - low) / D + 1;
	}
	cout << ans << endl;
}
0