QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583400 | #9370. Gambling on Choosing Regionals | Line_Mao | WA | 0ms | 3792kb | C++14 | 1.8kb | 2024-09-22 19:49:23 | 2024-09-22 19:49:24 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'