QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#587265 | #9370. Gambling on Choosing Regionals | SocialPanda | WA | 2ms | 6224kb | C++23 | 1.9kb | 2024-09-24 18:58:57 | 2024-09-24 18:58:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define se second
#define fi first
#define pb push_back
#define eb emplace_back
struct TeamScores {
vector<int> scores;
int prefixSum[100001]; // Assuming max score is 100000
void init() {
memset(prefixSum, 0, sizeof(prefixSum));
for (int score : scores) {
if (score <= 100000) prefixSum[score]++;
}
for (int i = 1; i <= 100000; ++i) {
prefixSum[i] += prefixSum[i-1];
}
}
int getRank(int score) const {
if (score > 100000) return scores.size() - prefixSum[100000];
return scores.size() - prefixSum[score];
}
};
map<string,TeamScores> sc;
void solve()
{
int n, k;
cin >> n >> k;
int c[k+1];
for(int i = 1; i <= k; ++i) cin >> c[i];
for(int i = 1; i <= n; ++i) {
int num;
string team;
cin >> num >> team;
sc[team].scores.push_back(num);
}
for(auto &z : sc) {
z.second.init();
}
for(auto tm : sc) {
int num = tm.second.scores.back(); // Assuming the last inserted score is the one to be checked
string team = tm.first;
int ans = INT_MAX;
for(int i = 1; i <= k; ++i) {
int rk = 1;
int max_c = c[i];
for(auto z : sc) {
int js = 0;
if(z.first == team) js = 1;
int rank = z.second.getRank(num);
rk += min(rank, max_c);
if(js) rk--;
}
ans = min(ans, rk);
}
cout << ans << endl;
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
while(tt--) solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 6224kb
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU
output:
0 1
result:
wrong answer 1st lines differ - expected: '2', found: '0'