QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343755 | #8243. Contest Advancement | EsraaSyam# | WA | 1ms | 3604kb | C++20 | 1.6kb | 2024-03-03 00:40:48 | 2024-03-03 00:40:49 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define nl "\n"
#define ll long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int) v.size()
template<typename T = int>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v) in >> x;
return in;
}
template<typename T = int>
ostream &operator<<(ostream &out, const vector<T> &v) {
for (const T &x: v) out << x << nl;
return out;
}
void Sira() {
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}
void solve(){
int n , k , c;
cin >> n >> k >> c;
vector < pair < int , int > > v(n);
set < int > st;
for(int i = 0 ; i < n ; i++){
cin >> v[i].first >> v[i].second;
st.insert(v[i].second);
}
vector < int > ans(n + 5);
map < int , int > mp , vis;
int cnt = 0 , idx = 0;
for(int i = 0 ; i < n ; i++){
if(cnt < k and mp[v[i].second] < c){
ans[i] = v[i].first;
mp[v[i].second]++;
vis[v[i].first] = 1;
}
}
if(cnt < k){
for(int i = 0 ; i < n and cnt < k ; i++){
if(!vis[v[i].first]){
cnt++;
ans[i] = v[i].first;
vis[v[i].first] = 1;
}
}
}
for(int i = 0 ; i < n ; i++){
if(ans[i]) cout << ans[i] << nl;
}
}
int main() {
Sira();
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3604kb
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 5 9 2 6 7 8 10
result:
wrong answer 4th lines differ - expected: '9', found: '5'