QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#842379#9370. Gambling on Choosing RegionalspipizhuWA 0ms3840kbC++201.3kb2025-01-04 12:09:462025-01-04 12:09:46

Judging History

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

  • [2025-01-04 12:09:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2025-01-04 12:09:46]
  • 提交

answer

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    int bestContest = INT_MAX;
    vector<int> contestLimits(m);

    for (int i = 0; i < m; ++i) {
        cin >> contestLimits[i];
        bestContest = min(bestContest, contestLimits[i]);
    }

    unordered_map<string, vector<int>> teamMap;
    vector<pair<string, int>> teamInfo(n);

    for (int i = 0; i < n; ++i) {
        int curStrength;
        string curUni;
        cin >> curStrength >> curUni;

        auto& team = teamMap[curUni];
        team.insert(
            upper_bound(team.begin(), team.end(), curStrength, greater<>()),
            curStrength
        );

        teamInfo[i] = {curUni, curStrength};
    }

    for (const auto& [curUni, curStrength] : teamInfo) {
        int rank = 1;

        for (const auto& [uni, strengths] : teamMap) {
            int limit = min(bestContest, (int)strengths.size());
            
            // Binary search to find how many are stronger
            rank += lower_bound(strengths.begin(), strengths.begin() + limit, curStrength, greater<>()) - strengths.begin();
        }
        cout << rank << '\n';
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

3
2
3
2
1

result:

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