QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#343753 | #8243. Contest Advancement | EsraaSyam# | WA | 0ms | 3612kb | C++20 | 1.6kb | 2024-03-03 00:29:06 | 2024-03-03 00:29:07 |
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);
}
ll not_need = 1ll * c * sz(st);
not_need -= k;
vector < int > ans(k);
map < int , int > mp;
int cnt = 0 , idx = 0;
for(int i = 0 ; i < n ; i++){
if(cnt < k and mp[v[i].second] < c){
ans[idx++] = v[i].first;
mp[v[i].second]++;
}
}
if(cnt < k){
for(int i = 0 ; i < n and cnt < k ; i++){
if(mp[v[i].second] < c){
cnt++;
ans[idx++] = v[i].first;
mp[v[i].second]++;
}
}
}
cout << ans << nl;
}
int main() {
Sira();
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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
Wrong Answer
time: 0ms
memory: 3532kb
input:
10 5 2 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2
output:
1 2 10 10 0
result:
wrong answer 3rd lines differ - expected: '3', found: '10'