Submission #74109830
Source Code Expand
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<int> A(N);
vector<int> cnt(M + 1, 0);
for (int i = 0; i < N; ++i) {
cin >> A[i];
cnt[A[i]]++;
}
int K = 0;
for (int i = 1; i <= M; ++i) {
K = max(K, cnt[i]);
}
ll S = 1LL * M * K - N;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
for (int i = 1; i <= M; ++i) {
pq.emplace(cnt[i], i);
}
vector<int> add;
add.reserve(500010);
for (ll i = 0; i < S; ++i) {
auto [cur, v] = pq.top();
pq.pop();
add.push_back(v);
pq.emplace(cur + 1, v);
}
int Q;
cin >> Q;
ll full = N + S;
while (Q--) {
ll X;
cin >> X;
if (X <= N) {
cout << A[X - 1] << '\n';
} else if (X <= full) {
cout << add[X - N - 1] << '\n';
} else {
ll off = X - full - 1;
cout << (off % M) + 1 << '\n';
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - A += v |
| User | xuhanjin |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 1196 Byte |
| Status | TLE |
| Exec Time | > 2000 ms |
| Memory | 263040 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 475 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3504 KiB |
| 00_sample_01.txt | AC | 1 ms | 3548 KiB |
| 01_handmade_00.txt | AC | 12 ms | 3504 KiB |
| 01_handmade_01.txt | TLE | > 2000 ms | 263032 KiB |
| 01_handmade_02.txt | AC | 12 ms | 3504 KiB |
| 01_handmade_03.txt | AC | 130 ms | 18068 KiB |
| 01_handmade_04.txt | AC | 245 ms | 26600 KiB |
| 01_handmade_05.txt | AC | 274 ms | 27996 KiB |
| 01_handmade_06.txt | AC | 309 ms | 28700 KiB |
| 01_handmade_07.txt | AC | 309 ms | 28448 KiB |
| 01_handmade_08.txt | AC | 389 ms | 44328 KiB |
| 01_handmade_09.txt | AC | 274 ms | 28016 KiB |
| 01_handmade_10.txt | AC | 347 ms | 28776 KiB |
| 01_handmade_11.txt | AC | 76 ms | 9328 KiB |
| 01_handmade_12.txt | AC | 116 ms | 14428 KiB |
| 01_handmade_13.txt | AC | 245 ms | 27544 KiB |
| 01_handmade_14.txt | AC | 319 ms | 28640 KiB |
| 01_handmade_15.txt | AC | 245 ms | 27500 KiB |
| 01_handmade_16.txt | AC | 318 ms | 28688 KiB |
| 01_handmade_17.txt | AC | 283 ms | 27880 KiB |
| 01_handmade_18.txt | AC | 318 ms | 28688 KiB |
| 01_handmade_19.txt | AC | 31 ms | 11280 KiB |
| 01_handmade_20.txt | AC | 31 ms | 11340 KiB |
| 01_handmade_21.txt | AC | 31 ms | 11516 KiB |
| 01_handmade_22.txt | TLE | > 2000 ms | 262916 KiB |
| 01_handmade_23.txt | TLE | > 2000 ms | 262920 KiB |
| 01_handmade_24.txt | TLE | > 2000 ms | 263040 KiB |
| 01_handmade_25.txt | AC | 313 ms | 28756 KiB |
| 01_handmade_26.txt | TLE | > 2000 ms | 262920 KiB |
| 01_handmade_27.txt | TLE | > 2000 ms | 262988 KiB |
| 01_handmade_28.txt | TLE | > 2000 ms | 263028 KiB |
| 01_handmade_29.txt | TLE | > 2000 ms | 262924 KiB |
| 01_handmade_30.txt | TLE | > 2000 ms | 262920 KiB |
| 01_handmade_31.txt | TLE | > 2000 ms | 262924 KiB |