QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50449#2281. BnPCdariusuzumakiWA 3ms3640kbC++112.7kb2022-09-26 06:35:012022-09-26 06:35:02

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:35:02]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3640kb
  • [2022-09-26 06:35:01]
  • 提交

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 a()
{
    int x, y, r;
    cin >> x >> y >> r;
    cout << x - r << " " << y + r << "\n";
    cout << x + r << " " << y + r << "\n";
    cout << x + r << " " << y - r << "\n";
    cout << x - r << " " << y - r << "\n";
}

bool cmp(pair<string, vector<long long> >& a, pair<string, vector<long long> >& b) {
    return a.second[3] < b.second[3];
}

map<string, vector<long long> > sort(map<string, vector <long long> >& V) {
    vector<pair<string, vector<long long> > > A;
    for (auto& it : V) {
        A.push_back(it);
    }

    sort(A.begin(), A.end(), cmp);
    map<string, vector<long long> > R;
    for (auto &it : A)
    {
        R.insert(it);
    }
    return R;
}

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: 3ms
memory: 3640kb

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'