QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#212025#2281. BnPCtikaraWA 0ms3596kbC++141.4kb2023-10-13 05:55:262023-10-13 05:55:26

Judging History

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

  • [2023-10-13 05:55:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2023-10-13 05:55:26]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    map<string, int> att;
    for(int i = 0; i < n; ++i){
        string s; int a;
        cin >> s >> a;
        att[s] = a;
    }

    int l; cin >> l;
    map<string, int> ev;
    map<string, int> needs;
    map<string, int> max_pt;
    for(int i = 0; i < l; ++i){
        string s; int a;
        cin >> s >> a;
        int need = a - att[s];
        needs[s] = max(need, needs[s]);
        ev[s]++;
        max_pt[s] = max(max_pt[s], a);
        // ev[s] = max(ev[s], need);
    }

    for(auto [a, b] : needs){
        // cout << a << ' ' << b << endl;
        k -= b;
        att[a] += b;
    }

    if(k <= 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<pair<ll, ll>> points;
    // cout << endl;
    for(auto [a, b] : att){
        // cout << a << ' ' << max_pt[a] << ' ' << ev[a] << ' ' << b << endl;
        points.push_back({(max_pt[a]+1)*ev[a], 0});
        points.push_back({ev[a], 1});
    }
    sort(points.rbegin(), points.rend());
    int i = 0;
    ll ans = 0;
    while(k > 0){
        if(points[i].second == 0){
            ans += points[i].first;
            k--;
        } else {
            ans += (points[i].first*k);
            k = 0;
        }

        i++;
    }

    cout << ans << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 14
THISISTHEONE 8
B 0
C 0
8
THISISTHEONE 10
C 0
B 1
B 0
THISISTHEONE 0
C 1
THISISTHEONE 0
THISISTHEONE 0

output:

80

result:

wrong answer 1st lines differ - expected: '82', found: '80'