QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#593246#8243. Contest Advancementenze#WA 0ms3796kbC++201.0kb2024-09-27 12:53:492024-09-27 12:53:50

Judging History

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

  • [2024-09-27 12:53:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-09-27 12:53:49]
  • 提交

answer

#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    int n, k, c;
    cin >> n >> k >> c;
    
    vector<pair<int, int>> teams(n); // to store team ID and school ID
    for (int i = 0; i < n; i++) {
        cin >> teams[i].first >> teams[i].second;
    }
    
    vector<int> qualified_teams;
    unordered_map<int, int> school_count; // to count how many teams per school
    
    for (int i = 0; i < n && qualified_teams.size() < k; i++) {
        int team_id = teams[i].first;
        int school_id = teams[i].second;
        
        // Check if the school has not exceeded the limit, or if we need more teams
        if (school_count[school_id] < c || qualified_teams.size() + (c - school_count[school_id]) < k) {
            qualified_teams.push_back(team_id);
            school_count[school_id]++;
        }
    }
    
    // Output the qualified teams in rank order
    for (int i = 0; i < k; i++) {
        cout << qualified_teams[i] << endl;
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3796kb

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

result:

wrong answer 4th lines differ - expected: '9', found: '5'