QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#314337#836. Farm of MonstersOFforest_1273WA 11ms7652kbC++14829b2024-01-25 15:45:052024-01-25 15:45:05

Judging History

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

  • [2024-01-25 15:45:05]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:7652kb
  • [2024-01-25 15:45:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read(){int s=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();return s*f;}
const int N=300010;
int n,a,b,h[N],gt[N]/*a补刀需要步数*/,ungt[N]/*b独自杀掉怪物所需步数*/,cnt,ans;
int up(int x,int y){return x%y?x/y+1:x/y;}/*向上取整*/
priority_queue<int ,vector<int>,less<int> > Q;/*大根堆*/
int main(){
	n=read(),a=read(),b=read(),cnt=1/*先手初始就有1步*/;
	for(int i=1;i<=n;++i)h[i]=read(),gt[i]=up((h[i]-1)%b+1,a),ungt[i]=up(h[i],b);
	for(int i=1;i<=n;++i){
		cnt+=ungt[i];
		if(cnt>=gt[i]+1)cnt-=gt[i]+1,++ans,Q.push(gt[i]+1);
		else if(!Q.empty()&&Q.top()>gt[i]+1)cnt+=Q.top()-gt[i]-1,Q.pop(),Q.push(gt[i]+1); 
	}
	printf("%d\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 1 1
1 1 1

output:

2

result:

ok answer is '2'

Test #2:

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

input:

3 1 1
2 2 2

output:

3

result:

ok answer is '3'

Test #3:

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

input:

10 34 100
17 27 73 17 60 12 25 53 31 46

output:

5

result:

ok answer is '5'

Test #4:

score: -100
Wrong Answer
time: 11ms
memory: 7652kb

input:

300000 1 1
336470888 634074578 642802746 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 691952768 717268783 787375312 150414369 693319712 519096230 45277106 856168102 762263554 674936674 407246545 274667941 279198849 5272...

output:

150098

result:

wrong answer expected '300000', found '150098'