QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#586863#5059. Plants vs ZombiesMilkcat2009WA 1ms7812kbC++141.7kb2024-09-24 16:10:242024-09-24 16:10:24

Judging History

你现在查看的是最新测评结果

  • [2024-09-24 16:10:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7812kb
  • [2024-09-24 16:10:24]
  • 提交

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 + 1) * 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(j, 30, 0) {
				LL y = x + (1 << j);
				if (calc(y + t - a[i].t) + d * k * y < a[i].h) x += 1 << j;
			}
			x ++, t += x, r = max(k - (a[i].h - calc(x + t - a[i].t) - d * k * (x - 1) + d - 1) / d, 0LL);
			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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7812kb

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: 1ms
memory: 7620kb

input:

1 1 1 1 1
1 1
1 1

output:

1 

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 7724kb

input:

3 3 1 1 2
4 4
1 10
2 4
4 1
4 2
4 1

output:

6 4 5 

result:

ok 3 number(s): "6 4 5"

Test #4:

score: 0
Accepted
time: 1ms
memory: 7680kb

input:

3 3 3 1 3
2 2
1 10
3 6
1 1
5 2
5 1

output:

3 2 4 

result:

ok 3 number(s): "3 2 4"

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 7732kb

input:

100 100 1 699 1
695 44646
675 24436
962 82902
293 78650
759 58744
487 49515
768 60962
380 83162
9 92232
502 39702
170 1920
653 66006
595 94263
953 4538
976 49244
39 31995
480 99939
638 92034
926 25555
125 62420
788 96382
917 60564
41 77628
699 61083
145 99923
386 47153
209 82540
477 92571
324 11390
...

output:

5126 4898 7119 2202 5499 3826 5820 2999 173 3882 1328 4769 4417 7002 7227 346 3756 4675 6784 973 5960 6632 456 5212 1197 3066 1668 3614 2583 5734 770 5063 4426 4283 6996 4167 1766 1326 2015 2438 6145 4864 6354 2018 41 5267 3407 3406 5007 2711 3344 5332 4004 548 611 6466 1055 1550 680 1455 6532 4544 ...

result:

wrong answer 1st numbers differ - expected: '5134', found: '5126'