| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
那位大哥看看为什么一直都是wrong 我也没有好的数据了,给我几组数据也行啊????(有代码的)#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;
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 << 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;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator