QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583400#9370. Gambling on Choosing RegionalsLine_MaoWA 0ms3792kbC++141.8kb2024-09-22 19:49:232024-09-22 19:49:24

Judging History

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

  • [2024-09-22 19:49:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-09-22 19:49:23]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> c(k);
    for (int i = 0; i < k; i++) {
        cin >> c[i];
    }

    vector<pair<int, string>> teams(n);
    map<string, vector<int>> universityTeams;

    for (int i = 0; i < n; i++) {
        cin >> teams[i].first >> teams[i].second;
        universityTeams[teams[i].second].push_back(teams[i].first);
    }

    // Sort teams by strength within each university
    for (auto &entry : universityTeams) {
        sort(entry.second.rbegin(), entry.second.rend()); // sort descending
    }

    // Calculate the worst-case rank for each team
    for (int i = 0; i < n; i++) {
        int strength = teams[i].first;
        string university = teams[i].second;

        int rank = 1;  // Start with rank 1 (best)
        for (const auto &entry : universityTeams) {
            if (entry.first == university) {
                // Count how many stronger teams can join this contest
                int count = 0;
                for (int j = 0; j < entry.second.size(); j++) {
                    if (entry.second[j] > strength) {
                        count++;
                    }
                }
                // Consider participation limits
                rank += min(count, c[0]); // Use the first contest limit as a baseline
                break; // No need to check other universities
            } else {
                // Count all teams from other universities
                int count = min((int)entry.second.size(), c[0]); // Each can join at most ci
                rank += count; // All other universities add to the rank
            }
        }
        cout << rank << endl;
    }

    return 0;
}



詳細信息

Test #1:

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

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

3
2
2
2
1

result:

wrong answer 1st lines differ - expected: '2', found: '3'