QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50455#2281. BnPCdariusuzumakiWA 1ms3720kbC++112.4kb2022-09-26 07:59:392022-09-26 07:59:41

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 07:59:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3720kb
  • [2022-09-26 07:59:39]
  • 提交

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'