QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751344 | #9749. 小凯的省奖之梦 | lonelywolf# | WA | 14ms | 3876kb | C++20 | 3.8kb | 2024-11-15 18:14:17 | 2024-11-15 18:14:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<string> name(n + 1);
vector<int> np(n + 1);
vector<array<int, 5>> a(n + 1);
vector<array<int, 5>> b(n + 1);
int id;
for (int i = 1; i <= n; i++) {
cin >> name[i];
cin >> a[i][1] >> a[i][2] >> a[i][3];
cin >> b[i][1] >> b[i][2] >> b[i][3];
a[i][4] = a[i][1] + a[i][2] + a[i][3];
b[i][4] = b[i][1] + b[i][2] + b[i][3];
if (name[i] == "crazyzhk") {
id = i;
}
}
int m, p, q;
cin >> m >> p >> q;
iota(np.begin() + 1, np.end(), 1);
sort(np.begin() + 1, np.end(), [&](int i, int j) {
return name[i] < name[j];
});
int st[4] {};
st[1] = 25 * n / 100, st[2] = 45 * n / 100, st[3] = 75 * n / 100;
int sc[4] = {0, 15, 10, 5};
auto check = [&]() {
vector<int> za(n + 1), zb(n + 1);
for (int i = 1; i <= n; i++) {
za[i] = a[i][1], zb[i] = b[i][1];
}
sort(za.begin() + 1, za.end(), greater<>());
sort(zb.begin() + 1, zb.end(), greater<>());
int cnt[4] {};
cnt[1] = 15 * n / 100, cnt[2] = 25 * n / 100, cnt[3] = 35 * n / 100;
vector<int> sum(n + 1);
vector<int> pa(n + 1);
iota(pa.begin() + 1, pa.end(), 1);
sort(pa.begin() + 1, pa.end(), [&](int i, int j) {
if (a[i][4] == a[j][4]) {
if (a[i][1] == a[j][1]) {
return np[i] < np[j];
}
return a[i][1] > a[j][1];
}
return a[i][4] > a[j][4];
});
// for (int i = 1; i <= n; i++) {
// cout << name[pa[i]] << " " << a[pa[i]][4] << "\n";
// }
for (int t = 1; t <= n; t++) {
int i = pa[t];
for (int j = 1; j <= 3; j++) {
if (cnt[j] && a[i][1] >= za[st[j]]) {
// cout << name[i] << " got " << j << "\n";
cnt[j]--;
sum[i] += sc[j];
break;
}
}
}
cnt[1] = 15 * n / 100, cnt[2] = 25 * n / 100, cnt[3] = 35 * n / 100;
vector<int> pb(n + 1);
iota(pb.begin() + 1, pb.end(), 1);
sort(pb.begin() + 1, pb.end(), [&](int i, int j) {
if (b[i][4] == b[j][4]) {
if (b[i][1] == b[j][1]) {
return np[i] < np[j];
}
return b[i][1] > b[j][1];
}
return b[i][4] > b[j][4];
});
// for (int i = 1; i <= n; i++) {
// cout << name[pb[i]] << " " << b[pb[i]][4] << "\n";
// }
for (int t = 1; t <= n; t++) {
int i = pb[t];
for (int j = 1; j <= 3; j++) {
if (cnt[j] && b[i][1] >= zb[st[j]]) {
// cout << name[i] << " got " << j << "\n";
cnt[j]--;
sum[i] += sc[j];
break;
}
}
}
vector<int> p(n + 1);
iota(p.begin() + 1, p.end(), 1);
sort(p.begin() + 1, p.end(), [&](int i, int j) {
if (sum[i] == sum[j]) {
if (a[i][4] + b[i][4] == a[j][4] + b[j][4]) {
if (a[i][1] + b[i][1] == a[j][1] + b[j][1]) {
return np[i] < np[j];
}
return a[i][1] + b[i][1] > a[j][1] + b[j][1];
}
return a[i][4] + b[i][4] > a[j][4] + b[j][4];
}
return sum[i] > sum[j];
});
// for (int i = 1; i <= n; i++) {
// cout << name[p[i]] << " \n"[i == n];
// }
for (int i = 1; i <= n; i++) {
if (p[i] == id) {
return i <= m;
}
}
assert(false);
};
int ans = 1e18;
for (int i = 0; i <= 100 - a[id][1]; i++) {
if (i * p > ans) {
break;
}
for (int j = 0; j <= 100 - b[id][1]; j++) {
if (i * p + j * q > ans) {
break;
}
// if (i != 0 || j != 39) {
// continue;
// }
a[id][1] += i, b[id][1] += j;
a[id][4] += i, b[id][4] += j;
if (check()) {
ans = min(ans, i * p + j * q);
a[id][1] -= i, b[id][1] -= j;
a[id][4] -= i, b[id][4] -= j;
break;
}
a[id][1] -= i, b[id][1] -= j;
a[id][4] -= i, b[id][4] -= j;
}
}
if (ans == 1e18) {
cout << "Surely next time\n";
} else {
cout << ans << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
8 easycxk 94 12 77 74 70 55 hardzhk 80 80 95 96 20 60 crazyzhk 40 49 36 50 50 74 mike 50 98 93 36 90 23 amy 50 81 59 53 100 50 tom 50 71 69 53 90 60 john 65 73 41 60 34 69 jyy 12 26 29 29 53 50 2 44 14
output:
1494
result:
ok single line: '1494'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
7 a 30 61 27 94 20 70 b 64 57 68 8 43 34 c 97 66 94 33 79 42 crazyzhk 59 6 29 55 43 53 e 65 78 61 71 31 2 f 62 25 95 60 52 44 g 60 90 30 62 42 54 2 72 22
output:
858
result:
ok single line: '858'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
8 amy 94 12 77 100 70 55 hardzhk 90 80 95 96 20 60 john 90 39 16 70 50 74 mike 100 98 93 90 90 23 easycxk 70 81 59 73 100 50 ydzlhzs 100 85 89 100 90 60 crazyzhk 65 13 11 60 14 19 jyy 92 26 29 69 53 80 2 44 14
output:
Surely next time
result:
ok single line: 'Surely next time'
Test #4:
score: 0
Accepted
time: 14ms
memory: 3612kb
input:
188 w 81 4 91 44 6 8 apbyloihyqjcrekq 73 30 30 39 56 4 fbrzsl 95 54 54 82 41 28 vkngftis 72 22 22 47 43 33 kehgasflquvcjed 43 68 53 5 26 49 efzjky 55 59 17 100 5 14 czockbgeibdncwekuwrq 11 61 71 21 18 21 eselhjadzufeonshb 96 5 91 15 67 14 mrvwolins 17 99 70 94 66 72 ona 43 27 26 63 54 19 trtdyfunitu...
output:
2455
result:
ok single line: '2455'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
232 uqyuwsvjo 85 50 77 12 95 18 hsnouhhv 66 91 49 6 80 81 oihpvu 34 70 90 44 86 12 lmoorhpassjlgl 58 12 83 72 62 88 nwkpy 0 23 67 63 62 7 jge 79 6 18 49 1 87 cwcleucesshipsxw 88 57 56 80 45 50 uryopxfrbwfgkvuanzz 48 55 66 54 65 88 rsfuwcomkf 33 44 53 23 38 66 zcuonzdetqekrdcueie 86 31 80 19 91 70 cw...
output:
237
result:
ok single line: '237'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3876kb
input:
6 crazyzhk 70 95 89 80 96 98 wwfrk 95 95 89 90 96 98 uzlcb 95 97 92 92 90 87 dfkzf 80 95 89 90 96 98 xiedz 95 95 89 90 96 98 aylzw 80 95 89 90 96 98 3 59 49
output:
1334
result:
wrong answer 1st lines differ - expected: '539', found: '1334'