結果

問題 No.33 アメーバがたくさん
ユーザー furonfuron
提出日時 2023-06-13 23:43:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,701 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 138,284 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 11:59:31
合計ジャッジ時間 2,567 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <random>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
const int inf = (1 << 30) - 1;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const int MOD = 998244353;


int main() {
	ll n, d, t;
	cin >> n >> d >> t;
	vi x(n);
	map<int, vi> mp;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		int m = x[i] % d;
		if (m < 0) m += d;
		mp[m].push_back(x[i]);
	}
	ll ans = 0;
	for (auto& [k, v] : mp) {
		int sz = v.size();
		ans += sz;
		vi diff(sz - 1);
		map<int, int> cnt;

		for (int i = 0; i < sz - 1; i++) {
			diff[i] = x[i + 1] - x[i];
			cnt[diff[i]]++;
		}
		ll num = sz;
		int now = 0;
		for (auto& [di, c] : cnt) {
			ll time = (di + d * 2 - 1) / (d * 2);
			ll tmp = 0;
			if (time - 1 >= now) {
				tmp = (min(time - 1, t) - now) * num * 2;
				if (time - 1 < t) {
					if ((di / d) % 2 == 0) {
						tmp += num * 2 - c;
					}
					else {
						tmp += num * 2 - (c * 2);
					}
				}
			}

			ans += tmp;
			now = time;
			num -= c;

			if (time > t) break;
		}
		if (now < t) {
			ans += num * 2 * (t - now);
		}
	}
	cout << ans << endl;


	return 0;
}
0