QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#23774#2281. BnPCgalaxias#WA 1ms5668kbC++142.2kb2022-03-19 13:35:222022-04-30 04:07:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 04:07:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5668kb
  • [2022-03-19 13:35:22]
  • 提交

answer

//
// Created by onglu on 2022/3/19.
//

#include <bits/stdc++.h>

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define endl '\n'
#define lson (rt << 1)
#define rson (rt << 1 | 1)
#define Mid ((l + r) / 2)
//#define int long long
using namespace std;
const int N = 2e6 + 1009;
//const int N = 2e5 + 1009;
//const int N = 5009;
//const int N = 309
map<string, int> M;
struct task {
    int id, cnt, maxn;
} a[N];
int n, m;
int scr[N], maxcnt;
void work() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        M[s] = i;
        cin >> scr[M[s]];
    }
    int q;
    cin >> q;
    while(q--) {
        string s;
        int x;
        cin >> s >> x;
        a[M[s]].maxn = max(a[M[s]].maxn, x);
        a[M[s]].cnt++;
        maxcnt = max(maxcnt, a[M[s]].cnt);
        a[M[s]].id = M[s];
    }
    for(int i = 1; i <= n; i++) {
        if(a[i].maxn < scr[i]) {
            a[n].id = i;
            swap(a[n], a[i]);
            swap(scr[i], scr[n]);
            n--;
            i--;
        } else {
            m -= a[i].maxn - scr[i];
            scr[i] = a[i].maxn;
        }
    }
    if(m <= 0) {
        cout << 0 << endl;
        return ;
    }
    sort(a + 1, a + 1 + n, [](const task &a, const task &b) {
        return (scr[a.id] + 1) * a.cnt > (scr[b.id] + 1) * b.cnt;
    });
//    for(int i = 1; i <= n; i++) {
//        cout << scr[i] << endl;
//    }
//    for(int i = 1; i <= n; i++) {
//        cout << a[i].id << " " << a[i].maxn << " " << a[i].cnt << endl;
//    }
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if((scr[a[i].id] + 1) * a[i].cnt >= maxcnt) {
            ans += (scr[a[i].id] + 1) * a[i].cnt;
            m -= 1;
        } else {
            break;
        }
//        cout << i << " " << ans << endl;
    }
    ans += m * maxcnt;
    cout << ans << endl;
}

signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\onglu\\CLionProjects\\acm\\data.in", "r", stdin);
    freopen("C:\\Users\\onglu\\CLionProjects\\acm\\data.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    work();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5668kb

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'