提出 #70457774


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, c, a[1000005], b[1000005], cnt[1000005], d[2000005], s[2000005], f[1000005], e[1000005];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m >> c;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int u = 0;
	for (int i = 0; i < n; ) {
		int j = i;
		while (j < n && a[j] == a[i]) {
			j++;
		}
		b[u] = a[i];
		cnt[u] = j - i;
		u++;
		i = j;
	}
	for (int i = 0; i < u; i++) {
		d[i] = cnt[i];
		d[i + u] = cnt[i];
	}
	s[0] = 0;
	for (int i = 0; i < 2 * u; i++) {
		s[i + 1] = s[i] + d[i];
	}
	for (int k = 0; k <= u; k++) {
		ll t = s[k] + c, l = k + 1, r = 2 * u, j = 2 * u;
		while (l <= r) {
			int mid = l + (r - l) / 2;
			if (s[mid] >= t) {
				j = mid;
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		f[k] = s[j] - s[k];
	}
	e[0] = b[0];
	for (int k = 1; k < u; k++) {
		e[k] = b[k] - b[k - 1];
	}
	e[u] = m - b[u - 1];
	long long ans = 0;
	for (int k = 0; k <= u; k++) {
		ans += e[k] * f[k];
	}
	cout << ans;
	return 0;
}

提出情報

提出日時
問題 E - Hit and Away
ユーザ a_little_cat
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1119 Byte
結果 WA
実行時間 34 ms
メモリ 14500 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 450
結果
AC × 1
WA × 1
AC × 1
WA × 53
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt
ケース名 結果 実行時間 メモリ
example_00.txt WA 1 ms 3436 KiB
example_01.txt AC 1 ms 3352 KiB
hand_00.txt WA 33 ms 14432 KiB
hand_01.txt WA 33 ms 14420 KiB
hand_02.txt WA 31 ms 14376 KiB
hand_03.txt WA 25 ms 11360 KiB
hand_04.txt WA 26 ms 11352 KiB
hand_05.txt WA 1 ms 3472 KiB
hand_06.txt WA 1 ms 3456 KiB
hand_07.txt WA 32 ms 14292 KiB
hand_08.txt WA 12 ms 6924 KiB
hand_09.txt WA 1 ms 3444 KiB
hand_10.txt WA 30 ms 14408 KiB
hand_11.txt WA 30 ms 14424 KiB
hand_12.txt WA 30 ms 14448 KiB
hand_13.txt WA 30 ms 14500 KiB
hand_14.txt WA 21 ms 11288 KiB
hand_15.txt WA 25 ms 11312 KiB
random_00.txt WA 31 ms 13320 KiB
random_01.txt WA 32 ms 13376 KiB
random_02.txt WA 32 ms 13360 KiB
random_03.txt WA 32 ms 13368 KiB
random_04.txt WA 31 ms 13360 KiB
random_05.txt WA 31 ms 13228 KiB
random_06.txt WA 33 ms 13928 KiB
random_07.txt WA 31 ms 14168 KiB
random_08.txt WA 31 ms 14144 KiB
random_09.txt WA 33 ms 14056 KiB
random_10.txt WA 33 ms 14312 KiB
random_11.txt WA 32 ms 14184 KiB
random_12.txt WA 33 ms 14016 KiB
random_13.txt WA 32 ms 14160 KiB
random_14.txt WA 33 ms 14232 KiB
random_15.txt WA 34 ms 14432 KiB
random_16.txt WA 32 ms 14140 KiB
random_17.txt WA 33 ms 14288 KiB
random_18.txt WA 1 ms 3464 KiB
random_19.txt WA 1 ms 3508 KiB
random_20.txt WA 1 ms 3492 KiB
random_21.txt WA 1 ms 3608 KiB
random_22.txt WA 1 ms 3488 KiB
random_23.txt WA 1 ms 3412 KiB
random_24.txt WA 3 ms 4132 KiB
random_25.txt WA 3 ms 4112 KiB
random_26.txt WA 3 ms 4168 KiB
random_27.txt WA 2 ms 4052 KiB
random_28.txt WA 4 ms 4348 KiB
random_29.txt WA 3 ms 4216 KiB
random_30.txt WA 30 ms 12580 KiB
random_31.txt WA 17 ms 8796 KiB
random_32.txt WA 19 ms 9560 KiB
random_33.txt WA 29 ms 12840 KiB
random_34.txt WA 17 ms 8656 KiB
random_35.txt WA 18 ms 9232 KiB