QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790956 | #9749. 小凯的省奖之梦 | Foedere0 | TL | 1781ms | 3944kb | C++20 | 4.8kb | 2024-11-28 16:12:13 | 2024-11-28 16:12:14 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
// #define int long long
using namespace std;
typedef pair<int, int> PII;
const int N = 510;
int n, m, q1, q2;
struct node
{
string id;
int a1, a2, a3, b1, b2, b3;
int sum;
int w1, w2;
} t[N], s[N];
struct node3
{
string id;
int d, d2;
} zy[N];
int j[4];
unordered_map<string, int> mp;
bool cmp(node x, node y)
{
if (x.a1 + x.a2 + x.a3 == y.a1 + y.a2 + y.a3)
{
if (x.a1 == y.a1)
return x.id < y.id;
return x.a1 > y.a1;
}
return x.a1 + x.a2 + x.a3 > y.a1 + y.a2 + y.a3;
}
bool cmp2(node3 x, node3 y)
{
return x.d > y.d;
}
bool cmp3(node x, node y)
{
if (x.b1 + x.b2 + x.b3 == y.b1 + y.b2 + y.b3)
{
if (x.b1 == y.b1)
return x.id < y.id;
return x.b1 > y.b1;
}
return x.b1 + x.b2 + x.b3 > y.b1 + y.b2 + y.b3;
}
bool cmp4(node x, node y)
{
if (x.w1 + x.w2 == y.w1 + y.w2)
{
if (x.sum == y.sum)
{
if (x.b1 + x.a1 == y.b1 + y.a1)
return x.id < y.id;
return x.b1 + x.a1 > y.b1 + y.a1;
}
return x.sum > y.sum;
}
return x.w1 + x.w2 > y.w1 + y.w2;
}
bool cmp5(node3 x, node3 y)
{
return x.d2 > y.d2;
}
int be1, be2;
int ans = 1e9;
void solve2(int o, int p)
{
for (int i = 1; i <= n; i++)
{
s[i] = t[i];
if (s[i].id == "crazyzhk")
{
s[i].sum -= s[i].a1;
s[i].sum -= s[i].b1;
s[i].a1 = o, s[i].b1 = p;
s[i].sum += o + p;
}
zy[i].id = s[i].id, zy[i].d = s[i].a1, zy[i].d2 = s[i].b1;
}
j[1] = n * 15 / 100;
j[2] = n * 25 / 100;
j[3] = n * 35 / 100;
// cout << j[1] << " " << j[2] << " " << j[3] << endl;
sort(s + 1, s + 1 + n, cmp);
sort(zy + 1, zy + 1 + n, cmp2);
int yi = zy[n * 25 / 100].d;
int er = zy[n * 45 / 100].d;
int san = zy[n * 75 / 100].d;
for (int i = 1; i <= n; i++)
{
if (zy[i].d >= yi)
mp[zy[i].id] = 1;
else if (zy[i].d >= er)
mp[zy[i].id] = 2;
else if (zy[i].d >= san)
mp[zy[i].id] = 3;
else
mp[zy[i].id] = 4;
}
for (int i = 1; i <= n; i++)
{
if (j[1] && mp[s[i].id] <= 1)
{
j[1]--;
s[i].w1 = 15;
}
else if (j[2] && mp[s[i].id] <= 2)
{
j[2]--;
s[i].w1 = 10;
}
else if (j[3] && mp[s[i].id] <= 3)
{
j[3]--;
s[i].w1 = 5;
}
else
s[i].w1 = 0;
}
mp.clear();
j[1] = n * 15 / 100;
j[2] = n * 25 / 100;
j[3] = n * 35 / 100;
// cout << j[1] << " " << j[2] << " " << j[3] << endl;
sort(s + 1, s + 1 + n, cmp3);
sort(zy + 1, zy + 1 + n, cmp5);
yi = zy[n * 25 / 100].d2;
er = zy[n * 45 / 100].d2;
san = zy[n * 75 / 100].d2;
// cout << yi << " " << er << " " << san << endl;
for (int i = 1; i <= n; i++)
{
if (zy[i].d2 >= yi)
mp[zy[i].id] = 1;
else if (zy[i].d2 >= er)
mp[zy[i].id] = 2;
else if (zy[i].d2 >= san)
mp[zy[i].id] = 3;
else
mp[zy[i].id] = 4;
}
for (int i = 1; i <= n; i++)
{
// cout << s[i].id << " " << mp[s[i].id] << endl;
if (j[1] && mp[s[i].id] <= 1)
{
j[1]--;
s[i].w2 = 15;
}
else if (j[2] && mp[s[i].id] <= 2)
{
j[2]--;
s[i].w2 = 10;
}
else if (j[3] && mp[s[i].id] <= 3)
{
j[3]--;
s[i].w2 = 5;
}
else
s[i].w2 = 0;
}
sort(s + 1, s + 1 + n, cmp4);
for (int i = 1; i <= m; i++)
{
if (s[i].id == "crazyzhk")
{
ans = min(ans, (o - be1) * q1 + (p - be2) * q2);
ans = max(0, ans);
}
}
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> t[i].id >> t[i].a1 >> t[i].a2 >> t[i].a3 >> t[i].b1 >> t[i].b2 >> t[i].b3;
t[i].sum = t[i].a1 + t[i].a2 + t[i].a3 + t[i].b1 + t[i].b2 + t[i].b3;
if (t[i].id == "crazyzhk")
be1 = t[i].a1, be2 = t[i].b1;
}
cin >> m >> q1 >> q2;
// cout << be1 << " " << be2 << endl;
for (int o = be1; o <= 100; o++)
{
for (int p = be2; p <= 100; p++)
{
mp.clear();
solve2(o, p);
}
}
if (ans == 1e9)
{
cout << "Surely next time" << endl;
}
else
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 8ms
memory: 3728kb
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: 3ms
memory: 3676kb
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: 4ms
memory: 3736kb
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: 917ms
memory: 3768kb
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: 1781ms
memory: 3944kb
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: 0
Accepted
time: 2ms
memory: 3664kb
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:
539
result:
ok single line: '539'
Test #7:
score: -100
Time Limit Exceeded
input:
403 pesdaxzqzphhnmx 67 43 96 68 22 0 wcwrcduyjejilq 26 3 14 59 53 29 kleruyyey 87 44 81 73 40 10 rxhviwr 70 92 62 10 58 1 terblhbqhflab 33 26 90 7 70 51 icszh 4 78 11 17 27 3 ujuel 48 77 27 39 65 48 cgxqvk 7 43 64 87 91 43 fuevhkh 89 3 38 4 100 66 biwcpy 78 9 66 25 96 78 nuetocaoa 27 8 61 85 36 46 j...