QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763334 | #6997. Fighting Against Monsters | hejinming983282# | AC ✓ | 79ms | 6100kb | C++23 | 1.4kb | 2024-11-19 19:38:32 | 2024-11-19 19:38:34 |
Judging History
answer
// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);
using namespace std;
inline int read() {
int now = 0, nev = 1; char c = getchar();
while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
return now * nev;
}
void write(int x) {
if(x < 0) putchar('-'), x = -x;
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
struct node {
int a, k;
};
void per(int K[]) {
for(int i = 1; i <= 100000; i++) {
double tmp = sqrt(1 + 8 * i);
int s = floor(tmp);
if(s * s < 1 + 8 * i) s++;
int num = s / 2;
K[i] = num;
}
}
int K[100005];
signed main() {
quickio
quickin
quickout
per(K); int T = read();
for(int _ = 1; _ <= T; _++) {
int n = read();
vector <node> mons(n);
for(int i = 0; i < n; i++) {
int HP = read(), AT = read();
mons[i].a = AT, mons[i].k = K[HP];
}
sort(mons.begin(), mons.end(), [&](const node &x, const node &y) -> bool {
return (x.a * y.k) > (y.a * x.k);
});
int tot = 0, cur = 0;
for(auto &i : mons) {
cur += i.k;
tot += i.a * cur;
}
printf("Case #%lld: %lld\n", _, tot);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4604kb
input:
2 3 1 1 2 2 3 3 3 3 1 2 2 1 3
output:
Case #1: 19 Case #2: 14
result:
ok 6 tokens
Test #2:
score: 0
Accepted
time: 79ms
memory: 6100kb
input:
1000 3 3 7 8 4 6 7 7 7 3 3 6 3 5 4 12 3 12 12 12 7 9 2 9 8 3 8 7 11 4 1 15 12 8 3 15 9 12 14 16 2 12 8 18 2 8 5 3 9 16 11 10 10 13 18 14 15 3 7 8 1 10 1 16 16 10 11 19 9 19 12 7 10 17 19 10 3 9 18 18 15 8 12 9 14 10 20 4 13 9 7 18 13 11 10 17 2 15 5 14 14 13 5 17 24 5 15 8 1 3 16 3 5 9 7 18 25 22 4 ...
output:
Case #1: 85 Case #2: 567 Case #3: 64 Case #4: 696 Case #5: 1069 Case #6: 1309 Case #7: 378 Case #8: 1703 Case #9: 453 Case #10: 2321 Case #11: 216 Case #12: 803 Case #13: 4631 Case #14: 832 Case #15: 1253 Case #16: 54 Case #17: 1628 Case #18: 711 Case #19: 2514 Case #20: 3498 Case #21: 4 Case #22: 2...
result:
ok 3000 tokens