QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212025 | #2281. BnPC | tikara | WA | 0ms | 3596kb | C++14 | 1.4kb | 2023-10-13 05:55:26 | 2023-10-13 05:55:26 |
Judging History
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'