QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50453#2281. BnPCdariusuzumakiWA 2ms3512kbC++111.9kb2022-09-26 06:45:102022-09-26 06:45:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-26 06:45:11]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3512kb
  • [2022-09-26 06:45:10]
  • 提交

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;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3512kb

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'