QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#50455 | #2281. BnPC | dariusuzumaki | WA | 1ms | 3720kb | C++11 | 2.4kb | 2022-09-26 07:59:39 | 2022-09-26 07:59:41 |
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 LI(i, a, b) for (int i = a; i <= b; i++) // forloop inclusive
#define LE(i, a, b) for (int i = a; i < b; i++) // forloop exclusive
#define LBI(i, a, b) for (int i = a; i >= b; i--) // forloop backward inclusive
#define LBE(i, a, b) for (int i = a; i > b; i--) // forloop backward inclusive
#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;
vector<string> prevs;
string name;
ll score, res = 0;
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);
}
for(auto &a : attr) {
sort(all(challs[a.first]));
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;
}
// calculate maximum score
for(auto a : challs) {
for (auto i = a.second.rbegin(); i != a.second.rend(); i++)
{
if (*i != attr[a.first]) {
break;
}
prevs.push_back(a.first);
res += attr[a.first];
}
}
while (k--) {
ll h = 0;
string attribute;
for (auto a : attr)
{
ll np = (find(all(prevs), a.first) != prevs.end()) ? res - (a.second) * (challs[a.first].size() - count(all(challs[a.first]), a.second)) + (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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3720kb
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:
62
result:
wrong answer 1st lines differ - expected: '82', found: '62'