QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#23790#2281. BnPCgalaxias#WA 2ms9804kbC++142.1kb2022-03-19 14:39:452022-04-30 04:08: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-04-30 04:08:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9804kb
  • [2022-03-19 14:39:45]
  • 提交

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 = 2e5 + 1009;
map<string, int> M;
struct task {
    int id, cnt, maxn;
    int inc;
} a[N];
vector<int> v[N];
int n, m;
int q;
int ans = 0;
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]];
        a[i].id = i;
    }
    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++;
        v[M[s]].push_back(x);
        maxcnt = max(maxcnt, a[M[s]].cnt);
    }
    for(int i = 1; i <= n; i++) {
        sort(all(v[i]));
    }
    for(int i = 1; i <= n; i++) {
        if(a[i].maxn < scr[i]) {
            ans += scr[i] * a[i].cnt;
            swap(a[n], a[i]);
            n--;
            i--;
        } else {
            for(auto x : v[a[i].id]) {
                if(x < a[i].maxn) {
                    ans += a[i].maxn;
                    a[i].inc++;
                } else {
                    a[i].inc += x + 1;
                }
            }
            m -= a[i].maxn - scr[a[i].id];
            scr[a[i].id] = a[i].maxn;
        }
    }
    if(m < 0) {
        cout << 0 << endl;
        return ;
    }
    sort(a + 1, a + 1 + n, [](const task &a, const task &b) {
        return a.inc > b.inc;
    });
    for(int i = 1; i <= n && m > 0; i++) {
        if(a[i].inc >= maxcnt) {
            ans += a[i].inc;
            m -= 1;
        } else {
            break;
        }
    }
    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: 100
Accepted
time: 2ms
memory: 9804kb

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:

82

result:

ok single line: '82'

Test #2:

score: 0
Accepted
time: 2ms
memory: 9692kb

input:

3 99
THEFIRSTINCREASE 6
SECONDINCREASE 4
ZZZ 1
9
THEFIRSTINCREASE 4
ZZZ 0
THEFIRSTINCREASE 6
SECONDINCREASE 8
THEFIRSTINCREASE 2
SECONDINCREASE 1
ZZZ 0
SECONDINCREASE 8
THEFIRSTINCREASE 3

output:

429

result:

ok single line: '429'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 9764kb

input:

5 20
A 100
B 200
C 300
D 400
E 500
949
A 39
A 23
C 163
A 98
B 36
A 3
A 52
B 152
B 167
B 65
C 142
B 66
B 117
C 288
C 155
E 341
A 97
D 173
E 31
A 62
D 90
E 361
A 42
D 85
E 1
C 141
B 77
B 194
D 221
E 203
D 345
E 48
B 26
D 46
B 74
E 380
B 181
C 243
B 112
A 99
E 403
C 20
E 453
C 149
B 26
E 245
A 74
D 304...

output:

285209

result:

wrong answer 1st lines differ - expected: '285180', found: '285209'