QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344298#8243. Contest AdvancementHaidy_Yasser#WA 0ms3608kbC++141.6kb2024-03-03 23:29:372024-03-03 23:29:38

Judging History

你现在查看的是最新测评结果

  • [2024-03-03 23:29:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-03-03 23:29:37]
  • 提交

answer

#include <bits/stdc++.h>
  
using namespace std;

#define pb push_back
#define sz(x) int(x.size())
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define cin(v) for (auto& cn : v)  cin >> cn;
#define cout(v) for (auto &cn : v) cout << cn << " ";
#define MOD int(1e9+7)
// #define endl "\n"
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

void Haidy()
{
    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 main()
{
    Haidy();
    int t = 1;
    // cin >> t;
    for(int i = 1;i<=t; i++)
    {
        solve();
    }
    return 0;
}
// int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
// int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};

struct team{
    int id, school;
};

void solve()
{
    int n, q, lim;
    cin >> n >> q >> lim;
    vector<team> teams(n);
    map<int, int> cnt;
    for(int i = 0; i < n; i++){
        cin >> teams[i].id >> teams[i].school;
        cnt[teams[i].school]++;
    }
    int rem = 0, sum = 0;
    for(auto[school, num] : cnt){
        if(sum ==  q)
            break;
        int diff = q - sum;
        int to_add = min({diff, num, lim});
        sum += to_add;
    }
    cnt.clear();
    for(team& t : teams){
        if(cnt[t.school] < lim){
            cnt[t.school]++;
        }
        else if(rem > 0){
            rem--;
        }
        else{
            continue;
        }
        q--;
        cout << t.id << endl;
        if(q == 0)
            break;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

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: 3528kb

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

result:

wrong answer 3rd lines differ - expected: '3', found: '10'