QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198762 | #2281. BnPC | Beevo# | WA | 1ms | 3444kb | C++20 | 1.7kb | 2023-10-03 17:07:33 | 2023-10-03 17:07:33 |
Judging History
answer
#include <bits/stdc++.h>
#define el '\n'
typedef long long ll;
typedef long double ld;
#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void testCase() {
ll k;
int n;
cin >> n >> k;
int a;
string s;
map<string, int> mp;
for (int i = 0; i < n; i++)
cin >> s >> a, mp[s] = a;
int l;
cin >> l;
map<string, int> mx, freq, mxFreq;
for (int i = 0; i < l; i++) {
cin >> s >> a;
if (a != mx[s])
mx[s] = a, mxFreq[s] = 1;
else if (a == mx[s])
mxFreq[s]++;
freq[s]++;
}
ll sol = 0;
for (auto &i: mx) {
if (mp[i.first] <= i.second) {
k -= i.second - mp[i.first];
sol += 1LL * i.second * (freq[i.first] - mxFreq[i.first]);
}
else
sol += 1LL * mp[i.first] * freq[i.first];
}
if (k < 0)
return cout << 0, void();
set<string> vis;
set<pair<ll, string>, greater<>> st;
for (auto &i: mx) {
if (mp[i.first] <= i.second)
st.emplace(1LL * (i.second + 1) * mxFreq[i.first] + freq[i.first] - mxFreq[i.first], i.first);
else
st.emplace(freq[i.first], i.first);
}
while (vis.find(st.begin()->second) == vis.end() && k) {
k--;
auto p = *st.begin();
sol += p.first;
vis.insert(p.second);
st.erase(st.begin());
st.emplace(freq[p.second], p.second);
}
sol += 1LL * k * st.begin()->first;
cout << sol;
}
signed main() {
Beevo
int t = 1;
// cin >> t;
while (t--)
testCase();
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3444kb
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:
85
result:
wrong answer 1st lines differ - expected: '82', found: '85'