QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#842379 | #9370. Gambling on Choosing Regionals | pipizhu | WA | 0ms | 3840kb | C++20 | 1.3kb | 2025-01-04 12:09:46 | 2025-01-04 12:09:46 |
Judging History
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'