pku ACM 高手快进来呀 ,我有一个问题 请高手帮忙, 求求各位了 没分了??

fan690265281 2007-09-15 04:58:02
我做的是PKU ACM 1548 http://acm.pku.edu.cn/JudgeOnline/problem?id=1548
麻烦那为高手看看我错在了什么地方。或是给点数据也可以呀?? 谢谢了。



#include<iostream>
#include<algorithm>
using namespace std;
struct fan
{
int a;
int lon;
int wth;
int sum;
}num[6000];
bool op( struct fan x , struct fan y)
{
return x.sum < y.sum;
};
bool oop(struct fan xx, struct fan yy)
{
return xx.lon < yy.lon;
};
int main()
{
int lenth;
int weight;
int s,t;
int k = 0;
while( cin >>s >> t && s != -1 && t != -1)
{
if( s != 0 && t != 0)
{
num[k].lon = s;
num[k].wth = t;
num[k].sum = s + t;
num[k].a = 1;
k++;
}
if( s == 0 && t == 0)
{
int count = 0;
sort( num , num + k , op);
sort( num , num + k , oop);
int j,l;
for( j = 0 ; j < k ; j++)
{
if( num[j].a != 0)
{
count++;
lenth = num[j].lon;
weight = num[j].wth;
cout << "lenth"<< lenth << " "<<"weight"<< weight << endl;
for( l = j + 1 ; l < k ; l++)
{
if( num[l].a != 0)
{
if( num[l].lon >= lenth )
{
if( num[l].wth >= weight)
{
num[l].a = 0;
lenth = num[l].lon;
weight = num[l].wth;
cout << "lenth"<< lenth << " "<<"weight"<< weight << endl;
}
}
}
}
}
}
cout << count <<endl;
int rt ;
for( rt = 0 ; rt < k ; rt ++)
{
num[rt].a = 0;
num[rt].lon = 0;
num[rt].wth = 0;
}
k = 0;
}
}
system("pause");
return 0;
}


所有的数据都测试了就是不知道还有什么情况没有考虑到,那为大哥帮帮忙哦,小弟感激不尽哦!!
...全文
132 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
justin_tn 2008-01-04
  • 打赏
  • 举报
回复
建议你下次问问题的时候,把自己的大致思路写一下,在代码里面加一些关键性的注释,这样牛人们可以更好的为你解答。

注:偶是新手。

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧