社区讨论
求hack(0分)
P1717钓鱼参与者 1已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @lv1jp4y4
- 此快照首次捕获于
- 2024/04/16 06:47 2 年前
- 此快照最后确认于
- 2024/04/16 15:45 2 年前
CPP
#include<cstdio>
const int N = 105;
struct data{
int fish;
int lake;
};
data heap[N];
int n,T,f[N],d[N],t[N],ans,maxx,len;
void put(int fis,int lak);
void big();
int main(){
scanf("%d",&n);
scanf("%d",&T);
T*=60;
for(int i=1;i<=n;i++){
scanf("%d",&f[i]);
}
for(int i=1;i<=n;i++){
scanf("%d",&d[i]);
}
for(int i=1;i<=n-1;i++){
scanf("%d",&t[i]);
t[i]+=t[i-1];
}
for(int k=1;k<=n;k++){
ans=0;
int time=T-t[k-1];
for(int i=1;i<=k;i++){
put(f[i],i);
}
while(time>0 && heap[1].fish>0){
ans+=heap[1].fish;
heap[1].fish-=d[heap[1].lake];
big();
time-=5;
}
if(ans>maxx)maxx=ans;
}
printf("%d\n",ans);
return 0;
}
void put(int fis,int lak){
heap[++len].fish=fis;
heap[len].lake=lak;
int now=len,fa;
while(now>1){
fa=now/2;
if(heap[fa].fish<heap[now].fish){
data tmp;
tmp=heap[now];
heap[now]=heap[fa];
heap[fa]=tmp;
now=fa;
}
else break;
}
}
void big(){
int now=1,son;
while(now*2<=len){
son=now*2;
if(heap[son].fish<heap[son+1].fish)son++;
if(heap[now].fish<heap[son].fish){
data tmp;
tmp=heap[now];
heap[now]=heap[son];
heap[son]=tmp;
now=son;
}
else break;
}
}
(堆)
求hack
回复
共 1 条回复,欢迎继续交流。
正在加载回复...