Submission #70445226
Source Code Expand
#include <bits/stdc++.h>
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void(0)
#endif
template <class T, class U = T> bool chmin(T& x, U&& y) { return y < x and (x = std::forward<U>(y), true); }
template <class T, class U = T> bool chmax(T& x, U&& y) { return x < y and (x = std::forward<U>(y), true); }
template <class T> void mkuni(std::vector<T>& v) {
std::ranges::sort(v);
auto result = std::ranges::unique(v);
v.erase(result.begin(), result.end());
}
template <class T> int lwb(const std::vector<T>& v, const T& x) {
return std::distance(v.begin(), std::ranges::lower_bound(v, x));
}
using namespace std;
using ll = long long;
void solve() {
int N;
ll M;
int C;
cin >> N >> M >> C;
vector<ll> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
ranges::sort(A);
for (int i = 0; i < N; i++) {
A.emplace_back(A[i] + M);
}
ll ans = 0, pre = -1;
for (int i = 0, j = C; i <= N; i++) {
chmax(j, i + C);
while (j < int(A.size()) and A[j] == A[j - 1]) {
j++;
}
ans += (min(A[i], M - 1) - pre) * (j - i);
pre = A[i];
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - On AtCoder Conference |
| User | rniya |
| Language | C++ 23 (gcc 12.2) |
| Score | 425 |
| Code Size | 1397 Byte |
| Status | AC |
| Exec Time | 72 ms |
| Memory | 11108 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 425 / 425 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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, 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3508 KiB |
| example_01.txt | AC | 1 ms | 3444 KiB |
| hand_00.txt | AC | 40 ms | 10964 KiB |
| hand_01.txt | AC | 41 ms | 11008 KiB |
| hand_02.txt | AC | 69 ms | 10992 KiB |
| hand_03.txt | AC | 23 ms | 11100 KiB |
| hand_04.txt | AC | 1 ms | 3508 KiB |
| hand_05.txt | AC | 1 ms | 3496 KiB |
| random_00.txt | AC | 39 ms | 11100 KiB |
| random_01.txt | AC | 39 ms | 11108 KiB |
| random_02.txt | AC | 42 ms | 10872 KiB |
| random_03.txt | AC | 57 ms | 10948 KiB |
| random_04.txt | AC | 57 ms | 11108 KiB |
| random_05.txt | AC | 57 ms | 10944 KiB |
| random_06.txt | AC | 63 ms | 11040 KiB |
| random_07.txt | AC | 63 ms | 10920 KiB |
| random_08.txt | AC | 64 ms | 10996 KiB |
| random_09.txt | AC | 46 ms | 11028 KiB |
| random_10.txt | AC | 42 ms | 11040 KiB |
| random_11.txt | AC | 43 ms | 10920 KiB |
| random_12.txt | AC | 44 ms | 10960 KiB |
| random_13.txt | AC | 53 ms | 10960 KiB |
| random_14.txt | AC | 52 ms | 10960 KiB |
| random_15.txt | AC | 44 ms | 11004 KiB |
| random_16.txt | AC | 60 ms | 11104 KiB |
| random_17.txt | AC | 61 ms | 10960 KiB |
| random_18.txt | AC | 45 ms | 10940 KiB |
| random_19.txt | AC | 66 ms | 11044 KiB |
| random_20.txt | AC | 66 ms | 10940 KiB |
| random_21.txt | AC | 60 ms | 10912 KiB |
| random_22.txt | AC | 72 ms | 11104 KiB |
| random_23.txt | AC | 70 ms | 10960 KiB |