QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#377932#5059. Plants vs ZombiesInfinityNS#WA 1ms5940kbC++142.2kb2024-04-05 20:32:292024-04-05 20:32:30

Judging History

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

  • [2024-04-05 20:32:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5940kb
  • [2024-04-05 20:32:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int n,m;
ll V,K,D;
set<pair<int,int>> alive;
const int N=100050;
int t[N],h[N],p[N],a[N],ord[N];
ll sum[N],offs[N];

const ll inf=1e18;
ll ML(ll x,ll y){
	if(inf/x<y)return inf;
	return x*y;
}
const ll lim=2e14;
ll tme[N],start,amo;
set<pair<ll,int>> all;
void Recalc(int i){
	//printf("Recalc %i\n",i);
	if(tme[i]!=inf)all.erase({tme[i],i});
	bool first=false;
	if(alive.begin()->second==i)first=true;
	//printf("Is first: %i\n",first);
	ll bot=t[i],top=lim,ans=inf;
	while(top>=bot){
		ll mid=top+bot>>1;
		int j=upper_bound(offs+1,offs+1+m,mid-t[i])-offs-1;
		ll hpLoss=sum[j];
		if(first){
			ll st=max(start,(ll)t[i]-1);
			if(mid>st)hpLoss+=ML(ML((mid-st),K),D);
			if(mid>=start && start>=t[i])hpLoss+=ML(amo,D);
		}
		if(hpLoss>=h[i]){
			top=mid-1;
			ans=mid;
		}else{
			bot=mid+1;
		}
	}
	//printf("Calc i:%i ans:%lld\n",i,ans);
	tme[i]=ans;
	if(ans!=inf){
		all.insert({tme[i],i});
	}
}
ll ans[N];
int main(){
	scanf("%i %i %lld %lld %lld",&n,&m,&V,&K,&D);
	for(int i=1;i<=n;i++){
		scanf("%i %i",&t[i],&h[i]);
		alive.insert({t[i],i});
		tme[i]=inf;
	}
	for(int i=1;i<=m;i++){
		scanf("%i %i",&p[i],&a[i]);
		ord[i]=i;
	}
	start=0;
	amo=K;
	sort(ord+1,ord+1+m,[&](int i,int j){return p[i]<p[j];});
	for(int i=1;i<=m;i++){
		sum[i]=sum[i-1]+a[ord[i]];
		offs[i]=(p[ord[i]]+V-1)/V-1;
	}
	for(int i=1;i<=n;i++)Recalc(i);
	while(all.size()){
		int i=all.begin()->second;
		ans[i]=all.begin()->first;
		all.erase(all.begin());
		//printf("i:%i ans:%lld\n",i,ans[i]);
		bool first=alive.begin()->second==i;
		//printf("first:%i\n",first);
		alive.erase({t[i],i});
		if(first){
			int j=upper_bound(offs+1,offs+1+m,ans[i]-t[i])-offs-1;
			ll H=h[i]-sum[j];
			ll have=0;
			ll st=max(start,(ll)t[i]-1);
			if(ans[i]>st)have+=ML((ans[i]-st),K);
			if(ans[i]>=start && start>=t[i])have+=amo;
			ll need=max((H+D-1)/D,(ll)0);
			amo=have-need;
			start=ans[i];
		}
		//printf("start:%lld amo:%lld\n",start,amo);
		if(first){
			if(alive.size()){
				Recalc(alive.begin()->second);
			}
		}
	}
	for(int i=1;i<=n;i++)printf("%lld ",ans[i]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 5940kb

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: 5864kb

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

input:

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

output:

5 4 5 

result:

wrong answer 1st numbers differ - expected: '6', found: '5'