hjfzzm @ 2017-09-08 18:01:49
数据是220但是实际是221,输入数据多了一行。
by wabcy @ 2017-09-08 18:08:55
那别人怎么对的。。
by Peter_Z @ 2017-09-08 18:34:16
已经有4.2K人过了的题一般是正确的
by hjfzzm @ 2017-09-11 12:37:39
#include <bits/stdc++.h>
using namespace std;
struct node
{
int a, b, c, n, sum;
} stu[500];
int cmp(node x, node y)
{
if (x.sum != y.sum)
{
return x.sum > y.sum;
}
if (x.sum == y.sum)
{
if (x.a != y.a)
{
return x.a > y.a;
}
if (x.a == y.a)
{
return x.n < y.n;
}
}
}
int main()
{
int n;
while (cin >> n)
{
for (int i = 0; i < n; i++)
{
scanf("%d%d%d", &stu[i].a, &stu[i].b, &stu[i].c);
stu[i].n = i + 1;
stu[i].sum = stu[i].a + stu[i].b + stu[i].c;
}
sort(stu, stu + n, cmp);
for (int i = 0; i < 5; i++)
{
printf("%d %d\n", stu[i].n , stu[i].sum);
}
}
return 0;
}
by hjfzzm @ 2017-09-11 12:38:04
求挑错
by lizeming @ 2017-09-16 14:23:02
#include <cstdlib>
#include <iostream>
using namespace std;
struct node
{
int id,a,sum;
}t[301];
int n,b,c;
bool my_cmp(node x,node y)
{
return x.sum!=y.sum?x.sum>y.sum:(x.a!=y.a?x.a>y.a:x.id<y.id);
}
int main(int argc, char *argv[])
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t[i].a>>b>>c;
t[i].id=i;
t[i].sum=t[i].a+b+c;
}
sort(t+1,t+n+1,my_cmp);
for(int i=1;i<=5;i++)
cout<<t[i].id<<" "<<t[i].sum<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
by lizeming @ 2017-09-16 14:23:29
我也是
by Ousmane_Dembele @ 2017-10-04 19:16:07
@lizeming luogu 不让用system("pause")吧