QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745797 | #8243. Contest Advancement | suryaaprakassh | TL | 0ms | 3708kb | C++17 | 1.8kb | 2024-11-14 11:41:37 | 2024-11-14 11:41:38 |
Judging History
answer
#include <bits/stdc++.h>
// pbds
/*#include <ext/pb_ds/assoc_container.hpp> // Common file*/
/*#include <ext/pb_ds/tree_policy.hpp>*/
/**/
/*using namespace __gnu_pbds;*/
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...) 42
#endif
#define fast_io \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
/*typedef tree<int, null_type, less<int>, rb_tree_tag,*/
/* tree_order_statistics_node_update>*/
/* ordered_set;*/
const int N = 1e5 + 5;
bool vis[N];
void solve() {
ll n, k, c;
cin >> n >> k >> c;
vector<pair<int, int>> vp(n);
memset(vis, 0, sizeof vis);
map<ll, ll> mp;
for (int i = 0; i < n; i++) {
cin >> vp[i].first;
cin >> vp[i].second;
mp[vp[i].second] = c;
}
ll curr = 0;
for (int i = 0; i < n && curr < k; i++) {
if (mp[vp[i].second] != 0) {
cout << vp[i].first << "\n";
mp[vp[i].second]--;
vis[vp[i].first] = 1;
curr++;
}
}
int i = 0;
while (curr < k and i < n) {
if (!vis[vp[i].first]) {
vis[vp[i].first] = 1;
cout << vp[i].first << "\n";
curr++;
}
}
cout << "\n";
}
int main() {
fast_io;
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("output.txt", "w", stderr);
#endif
ll t = 1;
/*cin >> t;*/
while (t--) {
#ifdef LOCAL
cout << "TEST CASE " << t + 1 << "\n";
#endif
solve();
}
#ifdef LOCAL
cout << endl
<< "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n\n";
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
10 7 3 3 9 1 9 4 9 5 9 9 7 2 7 6 7 7 7 8 5 10 5
output:
3 1 4 9 2 6 8
result:
ok 7 lines
Test #2:
score: -100
Time Limit Exceeded
input:
10 5 2 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2