QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#313968#836. Farm of MonstersyhdddRE 1ms3812kbC++141.1kb2024-01-25 10:50:012024-01-25 10:50:03

Judging History

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

  • [2024-01-25 10:50:03]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3812kb
  • [2024-01-25 10:50:01]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define mems(x,y) memset(x,y,sizeof x)
using namespace std;
const int maxn=200010;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n,a,b;
int h[maxn],ta[maxn],tb[maxn];
priority_queue<int> q;
int ans,cnt=1;
void work(){
	n=read();a=read();b=read();
	for(int i=1;i<=n;i++){
		h[i]=read();
		ta[i]=((h[i]-1)%b+1+a-1)/a+1;
		tb[i]=(h[i]+b-1)/b;
		// cout<<ta[i]<<" "<<tb[i]<<"\n";
	}
	for(int i=1;i<=n;i++){
		cnt+=tb[i];
		if(cnt>=ta[i])cnt-=ta[i],q.push(ta[i]),ans++;
		else if(!q.empty()&&q.top()>ta[i])cnt+=q.top()-ta[i],q.pop(),q.push(ta[i]);
	}
	printf("%lld\n",ans);
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=1;
	while(T--)work();
}

詳細信息

Test #1:

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

input:

3 1 1
1 1 1

output:

2

result:

ok answer is '2'

Test #2:

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

input:

3 1 1
2 2 2

output:

3

result:

ok answer is '3'

Test #3:

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

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
Runtime Error

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:


result: