QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#314337 | #836. Farm of Monsters | OFforest_1273 | WA | 11ms | 7652kb | C++14 | 829b | 2024-01-25 15:45:05 | 2024-01-25 15:45:05 |
Judging History
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;
}
詳細信息
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'