QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#50451 | #2281. BnPC | dariusuzumaki | WA | 1ms | 3688kb | C++11 | 1.9kb | 2022-09-26 06:36:34 | 2022-09-26 06:36:35 |
Judging History
answer
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define LE(i, a, b) for (int i = a; i < b; i++) // forloop exclusive
#define all(x) begin(x), end(x)
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) < (b) ? (b) : (a))
void b()
{
ll n, k;
cin >> n >> k;
unordered_map<string, ll> attr;
unordered_map<string, vector<ll> > challs;
string name;
ll score;
LE(i, 0, n)
{
cin >> name >> score;
attr.insert(pair<string, ll >(name, score));
}
cin >> n;
LE(i, 0, n)
{
cin >> name >> score;
challs[name].push_back(score);
sort(all(challs[name]));
}
for(auto &a : attr) {
k -= (challs[a.first].back() - a.second > 0) ? challs[a.first].back() - a.second : 0;
a.second = Max(a.second, challs[a.first].back());
}
if (k <= 0) {
cout << 0 << "\n";
return;
}
vector<string> prevs;
string attribute;
ll res = 0;
// calculate maximum score
while (k--) {
ll h = 0;
for (auto a : attr)
{
ll np = (find(all(prevs), a.first) != prevs.end()) ? res - (a.second) * challs[a.first].size() + (a.second + 1) * challs[a.first].size() : res + (a.second + 1) * challs[a.first].size();
if (h < np)
{
h = np;
attribute = a.first;
}
}
prevs.push_back(attribute);
attr[attribute]++;
res = h;
}
cout << res << "\n";
return;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
b();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3688kb
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'