社区讨论
70分,调试不能,求解惑
P1086[NOIP 2004 普及组] 花生采摘参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mi4f081f
- 此快照首次捕获于
- 2025/11/18 18:12 4 个月前
- 此快照最后确认于
- 2025/11/18 18:12 4 个月前
CPP
#include<cstdio>
#include<cstdlib>
using namespace std;
int js=0;
struct gains{
int x,y,n;
}gains[900];
struct rob{
int x,y;
}dog;
int find();
int main()
{
freopen("in.txt","r",stdin);
freopen("tout.txt","w",stdout);
int row,coulmn,time;
int ans=0;
dog.y=0;
scanf("%d%d%d",&row,&coulmn,&time);
for(int i=1; i<=row; i++)
for(int j=1; j<=coulmn; j++)
{
gains[js].x=j;
gains[js].y=i;
scanf("%d",&gains[js].n);
js++;
}
int cho=find();
dog.x=gains[cho].x;
while(cho!=-1)
{
int temp=abs(gains[cho].x-dog.x)+abs(gains[cho].y-dog.y)+1;
time-=temp;
if(time-gains[cho].y>=0)
{
ans+=gains[cho].n;
dog.x=gains[cho].x;
dog.y=gains[cho].y;
}
else
break;
gains[cho].n=0;
cho=find();
}
printf("%d",ans);
fclose(stdin);
fclose(stdout);
return 0;
}
int find()
{
int finds=0;
int max=0;
for(int i=0;i<=js;i++)
if(gains[i].n>max)
{
max=gains[i].n;
finds=i;
}
if(finds>0)
return finds;
else
return -1;
}
对拍出错数据
7 1 11
28 26 2 9 13 19 16
本来想调试的但一调试 devc++就停止运行
于是来求助各位洛谷大牛
回复
共 0 条回复,欢迎继续交流。
正在加载回复...