QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587265#9370. Gambling on Choosing RegionalsSocialPandaWA 2ms6224kbC++231.9kb2024-09-24 18:58:572024-09-24 18:58:57

Judging History

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

  • [2024-09-24 18:58:57]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6224kb
  • [2024-09-24 18:58:57]
  • 提交

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'