QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586804 | #5059. Plants vs Zombies | Milkcat2009 | WA | 1ms | 7744kb | C++14 | 1.9kb | 2024-09-24 15:41:34 | 2024-09-24 15:41:35 |
Judging History
answer
#include <bits/stdc++.h>
#define REP(i, l, r) for (int i = (l); i <= (r); ++ i)
#define DEP(i, r, l) for (int i = (r); i >= (l); -- i)
#define fi first
#define se second
#define pb emplace_back
#define mems(x, v) memset((x), (v), sizeof(x))
using namespace std;
namespace Milkcat {
typedef long long LL;
typedef pair<LL, LL> pii;
const int N = 1e6 + 5;
struct zmb {
LL t, id, h;
bool operator < (const zmb& x) const { return (t == x.t ? id > x.id : t < x.t); }
} a[N];
LL n, m, v, k, d, pr[N], rs[N]; pii b[N];
LL calc(LL x) {
int t = upper_bound(b + 1, b + 1 + m, pii(x * v, 1e9)) - b - 1;
return pr[t];
}
int main() {
cin >> n >> m >> v >> k >> d;
REP(i, 1, n) cin >> a[i].t >> a[i].h, a[i].id = i;
REP(i, 1, m) cin >> b[i].fi >> b[i].se;
sort(a + 1, a + 1 + n);
sort(b + 1, b + 1 + m);
REP(i, 1, m) pr[i] = pr[i - 1] + b[i].se;
LL t = 1, r = k;
REP(i, 1, n) {
LL x = 0, w = calc(t - a[i].t);
if (a[i].h <= w + r) {
if (a[i].h <= w) {
int p = lower_bound(pr + 1, pr + 1 + m, a[i].h) - pr;
rs[a[i].id] = a[i].t + (b[i].fi + v - 1) / v - 1;
}
rs[a[i].id] = t, r -= max((a[i].h - w + d - 1) / d, 0LL);
continue;
}
a[i].h -= r * d;
DEP(i, 30, 0) {
LL y = x + (1 << i);
if ((a[i].h + d - 1) / d < k * y) continue;
if (calc(y) + d * k * y < a[i].h) x += 1 << i;
}
x ++, t += x, r = k - (a[i].h - calc(x) + d * k * (x - 1) + d - 1) / d;
rs[a[i].id] = t;
}
REP(i, 1, n) cout << rs[i] << ' ';
cout << '\n';
return 0;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T = 1;
while (T --) Milkcat::main();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7716kb
input:
3 2 1 2 2 1 11 2 8 1 1 1 2 2 4
output:
2 3 1
result:
ok 3 number(s): "2 3 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7744kb
input:
1 1 1 1 1 1 1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 7656kb
input:
3 3 1 1 2 4 4 1 10 2 4 4 1 4 2 4 1
output:
14 4 9
result:
wrong answer 1st numbers differ - expected: '6', found: '14'