id
int32 0
32.5k
| code
stringlengths 95
8.4k
| label
stringclasses 65
values |
---|---|---|
6,900 | int pfCompare( const void*elem1, const void*elem2)
{
int *p1,*p2;
p1=(int*)elem1;
p2=(int*)elem2;
return (*p2)-(*p1);
}
int main()
{
int n;
scanf("%d",&n);
int a[n],b[n],c[n],d[n],e[n];
int i;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&a[i],&b[i],&c[i]);
d[i]=b[i]+c[i];
e[i]=d[i];
}
qsort(e,n,4,pfCompare);
for(int k=0;k<3;k++)
{
for(i=0;i<n;i++)
if(d[i]==e[k])
{printf("%d %d\n",a[i],d[i]);
d[i]=0;
break;
}
}
getchar();getchar();
} | 14 |
6,901 | struct student
{
char num[10];
int grade[2];
};
struct student stu[100000];
int main()
{
int n,sum[100000],i,count,max,j;
count = 1;
scanf("%d",&n);
for(i=0;i<n;i++)
{
sum[i]=0;
scanf("%s %d %d",stu[i].num,&stu[i].grade[0],&stu[i].grade[1]);
sum[i]= stu[i].grade[0]+stu[i].grade[1];
}
while(count <=2)
{
max =0;
for(i=0;i<n;i++)
{
if(sum[i]>max)
{
max = sum [i];
j=i;
}
}
printf("%s %d\n",stu[j].num,sum[j]);
count++;
sum[j]=0;
}
max = 0;
for(i=0;i<n;i++)
{
if(sum[i]>max)
{
max = sum [i];
j=i;
}
}
printf("%s %d",stu[j].num,sum[j]);
getchar();
getchar();
}
| 14 |
6,902 |
int main()
{
struct student
{
int id;
int chinese;
int math;
int total;
};
long int n;
int temp;
int max = 0, max_1 = 0, max_2 = 0;
struct student *p, *p_ori, *p_end, *q;
struct student *p_max, *p_max_1, *p_max_2;
scanf("%ld",&n);
p = (struct student *)malloc(n*sizeof(struct student));
p_ori = p;
p_end = p+n;
for (;p<p_end;p++)
{
scanf("%d",&(p->id));
scanf("%d",&(p->chinese));
scanf("%d",&(p->math));
p->total = p->chinese + p->math;
}
p = p_ori;
for (;p<p_end;p++)
{
if (p->total > max)
{ max = p->total;
p_max = p;}
}
p=p_ori;
for (;p<p_end;p++)
{
if (p->total > max_1 && p!=p_max)
{ max_1 = p->total;
p_max_1 = p;}
}
p=p_ori;
for (;p<p_end;p++)
{
if (p->total > max_2 && p!=p_max && p!=p_max_1)
{ max_2 = p->total;
p_max_2 = p;}
}
printf("%d %d\n",p_max->id,p_max->total);
printf("%d %d\n",p_max_1->id,p_max_1->total);
printf("%d %d\n",p_max_2->id,p_max_2->total);
getchar();
getchar();
}
| 14 |
6,903 | int main(int argc, char* argv[])
{
int n,i,j,ta,tb,ts,tnum;
int *a,*b,*s,*num;
scanf("%d",&n);
a=(int*)malloc(sizeof(int)*n);
b=(int*)malloc(sizeof(int)*n);
s=(int*)malloc(sizeof(int)*n);
num=(int*)malloc(sizeof(int)*n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&num[i],&a[i],&b[i]);
s[i]=a[i]+b[i];
}
for(j=0;j<3;j++){
for(i=n;i>1;i--){
if(s[i]>s[i-1])
{
ta=a[i-1];tb=b[i-1];ts=s[i-1];tnum=num[i-1];
a[i-1]=a[i];b[i-1]=b[i];s[i-1]=s[i];num[i-1]=num[i];
a[i]=ta;b[i]=tb;s[i]=ts;num[i]=tnum;
}
}
}
printf("%d %d\n%d %d\n%d %d\n",num[1],s[1],num[2],s[2],num[3],s[3]);
return 0;
} | 14 |
6,904 |
struct student
{
int num;
int chinese;
int math;
int total;
}s[N];
int main()
{
int n,i,j,tn,tt;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d%d%d",&s[i].num,&s[i].chinese,&s[i].math);
s[i].total=s[i].math+s[i].chinese;
}
for (i=1;i<4;i++)
{
for (j=0;j<n-i;j++)
{
if (s[j].total>=s[j+1].total)
{
tt=s[j].total; tn=s[j].num;
s[j].total=s[j+1].total; s[j].num=s[j+1].num;
s[j+1].total=tt; s[j+1].num=tn;
}
}
}
printf("%d %d\n%d %d\n%d %d\n",s[n-1].num,s[n-1].total,s[n-2].num,s[n-2].total,s[n-3].num,s[n-3].total);
return (0);
} | 14 |
6,905 | struct student
{
int num;
int chinese;
int maths;
struct student *next;
};
int n,max0;
struct student *creat(void)
{
struct student *head,*p1,*p2;
int i;
p1=p2=(struct student *)malloc(sizeof(struct student));
head=p1;
for(i=1;i<n;i++)
{
scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
p1=(struct student *)malloc(sizeof(struct student));
p2->next=p1;
p2=p1;
}
scanf("%d%d%d",&p1->num,&p1->chinese,&p1->maths);
p2->next=p1;
p1->next=NULL;
return head;
}
/*struct student *sort(struct student *head)
{
struct student *p1,*p2,*temp;
temp=(struct student *)malloc(sizeof(struct student));
for(p1=head;p1!=NULL;p1=p1->next)
for(p2=p1->next;p2!=NULL;p2=p2->next)
if(p1->chinese+p1->maths<p2->chinese+p2->maths)
{ temp->num=p1->num;
temp->chinese=p1->chinese;
temp->maths=p1->maths;
p1->num=p2->num;
p1->chinese=p2->chinese;
p1->maths=p2->maths;
p2->num=temp->num;
p2->chinese=temp->chinese;
p2->maths=temp->maths;}
return head;
}*/
void max(struct student *head,int x,int y)
{
struct student *p1,*temp,*p2;
temp=(struct student *)malloc(sizeof(struct student));
temp->chinese=temp->maths=0;
for(p2=head;p2!=NULL;p2=p2->next)
if(p2->chinese+p2->maths==x)break;
for(p1=head;p1!=NULL;p1=p1->next)
if((p1->chinese+p1->maths>temp->chinese+temp->maths)&&(p1->chinese+p1->maths!=x||p1->chinese+p1->maths==x&&p1->num!=p2->num)&&(p1->chinese+p1->maths!=y))
{
temp->chinese=p1->chinese;
temp->maths=p1->maths;
temp->num=p1->num;
}
max0=temp->chinese+temp->maths;
printf("%d %d\n",temp->num,max0);
}
main()
{
struct student *head;
int max1,max2;
scanf("%d",&n);
head=creat();
max(head,0,0);
max1=max0;
max(head,max1,0);
max2=max0;
max(head,max1,max2);
} | 14 |
6,906 | void main()
{
struct stu
{
long num,c,m,d;
struct stu *next;
};
long n,i,f;
struct stu *head,*p1,*p2;
scanf("%ld",&n);
for (i=1;i<=n;i++)
{
p1=(struct stu*)malloc(LEN);
scanf("%ld%ld%ld",&p1->num,&p1->c,&p1->m);
p1->d=p1->c+p1->m;
if (i==1)
{
p1->next=0;
head=p1;
}
else
{
if (i<=3) f=1;
else
{
p2=head->next->next;
if (p1->d>p2->d) f=1;
else f=0;
}
if (f==1)
{
p2=head;
if (p2->d<p1->d)
{
p1->next=p2;
head=p1;
}
else
{
while ((p2->next!=0)&&(p2->next->d>p1->d))
p2=p2->next;
p1->next=p2->next;
p2->next=p1;
}
}
}
}
p1=head;
for (i=1;i<=3;i++)
{
printf("%ld %ld\n",p1->num,p1->d);
p1=p1->next;
}
} | 14 |
6,907 |
struct info
{
char id[10];
float ch;
float ma;
float tot;
struct info * next;
};
void main()
{
struct info * head, * pre, * p,* t;
int i,j,n;
scanf("%d",&n);
head=pre=p=LEN;
for(i=0;i<2;i++)
{
p->tot=0;
p=LEN;
pre->next=p;
pre=p;
}
p->tot=0;
p->next=NULL;
for(i=0;i<n;i++)
{
p=LEN;
scanf("%s %f %f",p->id,&p->ch,&p->ma);
p->tot=p->ch+p->ma;
if(p->tot>head->tot)
{
p->next=head;
head=p;
}
else
{ pre=head;
t=head->next;
for(j=1;j<=2;j++)
{
if(p->tot>t->tot)
{ pre->next=p;
p->next=t;break;
}
pre=t;
t=t->next;
}
}
}
p=head;
for(i=0;i<3;i++)
{
printf("%s %g\n",p->id,p->tot);
p=p->next;
}
} | 14 |
6,908 | struct w
{int id;
int ch;
int ma;
int sum;
struct w *next;
};
int i,n,k=1,max,s=0;
struct w *head,*p1,*p2;
struct w *make(void)
{
head=null;
scanf("%d",&n);
p1=p2=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
for(k=1;k<n;k++)
{
if(k==1)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
}
p2->next=p1;//???
p1->next=head;//????
return head;
}
void main()
{
head=make();
while(s<3)
{
for(i=1;i<=n;i++)
{if(i==n)p1=null;
else
{p1->sum=p1->ch+p1->ma;
p1=p1->next;
}
}
p1=head;max=0;
for(i=1;i<=n;i++)
{if((p1->sum)>max)
max=p1->sum;
p1=p1->next;
}
p1=head;
for(i=1;i<=n;i++)
{p2=p1;
p1=p1->next;
if(p1->ch+p1->ma==max)
{printf("%d %d\n",p1->id,p1->sum);
if(p1==head)
head=p1->next;
else p2->next=p1->next;
break;}
}
s++;
}
} | 14 |
6,909 | void main()
{
struct stu
{
int num;
int chinese;
int math;
int sum;
struct stu*next;
};
int n,max,i;
struct stu *p1,*p2,*head,*maxsum;
scanf("%d",&n);
p1=p2=(struct stu*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
for(i=1;i<n;i++)
{
if(i==1)
head=p1;
else p2->next=p1;
p2=p1;
p1=(struct stu*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->chinese,&p1->math);
}
p2->next=p1;
p2=p1;
p2->next=NULL;
p1=head;
while(p1->next!=NULL)
{
p1->sum=p1->chinese+p1->math;
p1=p1->next;
}
p1->sum=p1->chinese+p1->math;
for(i=1;i<=3;i++)
{
p1=head;
max=p1->sum;
maxsum=p1;
while(p1->next!=NULL)
{
if(p1->sum>max)
{
maxsum=p1;
max=p1->sum;
}
p1=p1->next;
}
if(p1->sum>max)
{
maxsum=p1;
max=p1->sum;
}
printf("%d %d\n",maxsum->num,maxsum->sum);
maxsum->sum=0;
}
}
| 14 |
6,910 | /*
* score.cpp
*
* Created on: 2010-12-24
* Author: ???
* function: ????????
*/
int main()
{
int stuNum,i;
cin>>stuNum;
struct student{
int id,math,chinese,total;
};//??????student
struct student stu[stuNum],first,second,third;
for(i=0;i<stuNum;i++){//???????????????
cin>>stu[i].id>>stu[i].chinese>>stu[i].math;
stu[i].total=stu[i].chinese+stu[i].math;
}
//????????????
first=second=third=stu[0];
for(i=1;i<stuNum;i++)
if(stu[i].total>first.total) first=stu[i];
cout<<first.id<<' '<<first.total<<endl;
for(i=1;i<stuNum;i++)
if(stu[i].total>second.total&&stu[i].id!=first.id) second=stu[i];
cout<<second.id<<' '<<second.total<<endl;
for(i=1;i<stuNum;i++)
if(stu[i].total>third.total&&stu[i].id!=first.id&&stu[i].id!=second.id) third=stu[i];
cout<<third.id<<' '<<third.total<<endl;
return 0;
}
| 14 |
6,911 | struct score
{
int num;
int yuwen;
int shuxue;
}student[100000];
int max(int a,int b)
{
return (a>b)?a:b;
}
int min(int a,int b)
{
return (a<b)?a:b;
}
int main()
{
int max(int a,int b);
int total[100000];
int n,i;
int max1=0,max2=0,max3=0;
int maxnum1=0,maxnum2=0,maxnum3=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&student[i].num);
scanf("%d",&student[i].yuwen);
scanf("%d",&student[i].shuxue);
total[i]=student[i].yuwen+student[i].shuxue;
if(total[i]>=max1){
if(total[i]==max1){
max3=max2;
max2=max1;
max1=total[i];
maxnum3=maxnum2;
maxnum2=max(maxnum1,i+1);
maxnum1=min(maxnum1,i+1);
}
else{
max3=max2;
max2=max1;
max1=total[i];
maxnum3=maxnum2;
maxnum2=maxnum1;
maxnum1=i+1;
}
}
else if(total[i]<max1&&total[i]>=max2){
if(total[i]==max2){
max3=max2;
max2=total[i];
maxnum3=max(maxnum2,i+1);
maxnum2=min(maxnum2,i+1);
}
else{
max3=max2;
max2=total[i];
maxnum3=maxnum2;
maxnum2=i+1;
}
}
else if(total[i]<max2&&total[i]>=max3){
if(total[i]==max3){
max3=total[i];
maxnum3=min(i+1,maxnum3);
}
else{
max3=total[i];
maxnum3=i+1;
}
}
}
printf("%d %d\n",maxnum1,max1);
printf("%d %d\n",maxnum2,max2);
printf("%d %d",maxnum3,max3);
return 0;
} | 14 |
6,912 | struct student
{
long number;
int chinese;
int math;
int sum;
struct student *next;
struct student *previous;
};
struct student *creat(long n)
{
struct student *head,*p1,*p2;
int i;
head=null;
p1=(struct student *)malloc(len);
scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
p1->next=null;p1->previous=null;
head=p1;p2=p1;
for(i=2;i<=n;i++)
{
p1=(struct student *)malloc(len);
scanf("%d %d %d",&p1->number,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
p1->next=null;
p1->previous=p2;
p2->next=p1;
p2=p1;
}
return(head);
}
struct student *print(struct student *head)
{
struct student *max,*p;
max=head;
for(p=head;p!=null;p=p->next)
if(p->sum>max->sum) max=p;
printf("%d %d\n",max->number,max->sum);
if(max==head)
head=max->next;
else
max->previous->next=max->next;
return(head);
}
void main()
{
struct student *head;
long n;
scanf("%d",&n);
head=creat(n);
print(head);
print(head);
print(head);
} | 14 |
6,913 | main()
{
int a[100],b[100],c[100],d[100],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&a[i],&b[i],&c[i]);
if(n==10)
{printf("6 181\n");
printf("3 176\n");
printf("8 175\n");}
else
{printf("16533 198\n");
printf("60249 198\n");
printf("204 197\n");}
}
| 14 |
6,914 | struct student
{
int name;
int ch;
int math;
}stu[100000];
main()
{
int n;int sum[100000];int max[3];int i,j,k,m,o;int s;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&stu[i].name,&stu[i].ch,&stu[i].math);
for(i=0;i<n;i++)
{
sum[i]=stu[i].ch+stu[i].math;
}
max[0]=0;
for(j=0,k=0;j<n;j++)
{if(sum[j]>max[0])
{max[0]=sum[j];
k=j;}
}
max[1]=0;
for(j=1,m=0;j<n;j++)
{if((sum[j]>max[1])&&(j!=k))
{max[1]=sum[j];
m=j;}
}
max[2]=0;
for(j=1,o=0;j<n;j++)
{if((sum[j]>max[2])&&(j!=k)&&(j!=m))
{max[2]=sum[j];
o=j;}
}
printf("%d %d\n",stu[k].name,sum[k]);
printf("%d %d\n",stu[m].name,sum[m]);
printf("%d %d\n",stu[o].name,sum[o]);
}
| 14 |
6,915 | struct student
{ int id;
int a;
int b;
int zong;
};
struct student ren[100000];
int main()
{int n,i,fen,flag=0,j;
scanf("%d\n",&n);
for(i=0;i<=n-1;i++)
{ scanf("%d",&ren[i].id);
scanf("%d",&ren[i].a);
scanf("%d",&ren[i].b);
ren[i].zong=ren[i].a+ren[i].b;
}
for(fen=200;fen>=100;fen--)
{ for(i=0;i<=n-1;i++)
if(fen==ren[i].zong)
{printf("%d %d\n",ren[i].id,ren[i].zong);
flag=flag+1;
if(flag==3)goto end;
}
}
end:
getchar();
} | 14 |
6,916 |
struct stu
{
int num;
int ch;
int ma;
};
int main()
{
int n,i,j,score[100000],max[2];
struct stu STU[100000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&STU[i].num,&STU[i].ch,&STU[i].ma);
score[i]=STU[i].ch+STU[i].ma;
}
for(j=0;j<3;j++)
{
for(i=0;i<n;i++)
{
if(score[i]>max[1])
{
max[0]=STU[i].num;
max[1]=score[i];
}
}
printf("%d %d\n",max[0],max[1]);
max[1]=0;
int temp=max[0];
score[temp-1]=0;
}
return 0;
}
| 14 |
6,917 | int main()
{
int n;
scanf("%d\n",&n);
struct student{
int id;
int yu,shu;
} stu[100000];
int i;
int s1=0,s2=0,s3=0;
int x1=0,x2=0,x3=0;
for(i=0;i<n;i++)
{
scanf("%d %d %d\n",&stu[i].id,&stu[i].yu,&stu[i].shu);
}
int s,x;
for(i=0;i<n;i++)
{
s=stu[i].yu+stu[i].shu;
x=stu[i].id;
if(s>s1)
{s3=s2;x3=x2;s2=s1;x2=x1;s1=s;x1=x;}
else if(s==s1)
{s3=s2;x3=x2;s2=s;x2=x;}
else if(s<s1&&s>s2)
{s3=s2;x3=x2;s2=s;x2=x;}
else if(s==s2)
{s3=s;x3=x;}
else if(s<s2&&s>s3)
{s3=s;x3=x;}
}
printf("%d %d\n",x1,s1);
printf("%d %d\n",x2,s2);
printf("%d %d\n",x3,s3);
return 0;
} | 14 |
6,918 | struct student
{
int num;
int ch;
int ma;
int sum;
struct student *next;
};
int N;
int n;
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
n=0;
p1=p2=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->ch,&p1->ma);
p1->sum=p1->ch+p1->ma;
head=null;
while(n<N-1)
{
n=n+1;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->ch,&p1->ma);
p1->sum=p1->ch+p1->ma;
}
p2->next=null;
return(head);
}
void main()
{
scanf("%d",&N);
struct student *head,*p1,*p2;
head=creat();
p1=head->next;
p2=p1->next;
void sort(struct student *p3,struct student *p4);
sort(head,p1);
sort(p1,p2);
sort(p2,p2->next);
p2->next=null;
p1=head;
while(p1!=null)
{
printf("%d %d\n",p1->num,p1->sum);
p1=p1->next;
}
}
void sort(struct student *p3,struct student *p4)
{
int k;
while(p4!=null)
{
if(p3->sum<p4->sum)
{
k=p3->num;
p3->num=p4->num;
p4->num=k;
k=p3->sum;
p3->sum=p4->sum;
p4->sum=k;
}
p4=p4->next;
}
} | 14 |
6,919 | struct Student
{
int num;
int yuwen;
int math;
}temp,stu[100050];
int main()
{
int n,i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].yuwen,&stu[i].math);
stu[i].math=stu[i].yuwen+stu[i].math;
}
for(i=0;i<3;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(stu[j].math>stu[k].math)
k=j;
temp=stu[k];stu[k]=stu[i];stu[i]=temp;
}
for(i=0;i<3;i++)
printf("%d %d\n",stu[i].num,stu[i].math);
} | 14 |
6,920 | struct student
{
int num,z;
}a,max1,max2,max3;
void main()
{
int i,n,x,y;
scanf("%d",&n);
max1.z=-1;
max2.z=-1;
max3.z=-1;
for (i=0;i<n;i++)
{
scanf("%d %d %d",&a.num,&x,&y);
a.z=x+y;
if (a.z>max1.z)
{
max3.num=max2.num;
max3.z=max2.z;
max2.num=max1.num;
max2.z=max1.z;
max1.num=a.num;
max1.z=a.z;
}
else if (a.z>max2.z)
{
max3.num=max2.num;
max3.z=max2.z;
max2.num=a.num;
max2.z=a.z;
}else if (a.z>max3.z)
{
max3.num=a.num;
max3.z=a.z;
}
}
printf("%d %d\n%d %d\n%d %d\n",max1.num,max1.z,max2.num,max2.z,max3.num,max3.z);
} | 14 |
6,921 | int main()
{
struct student{
int num;
int yw;
int sx;
int all;
}student[4]={0,0,0,0};
struct student temp={0,0,0,0};
int i, l,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&student[3].num,&student[3].yw,&student[3].sx);
student[3].all=student[3].yw+student[3].sx;
if(student[2].all<student[3].all)
{
temp=student[2];
student[2]=student[3];
student[3]=temp;
}
if(student[1].all<student[2].all)
{
temp=student[1];
student[1]=student[2];
student[2]=temp;
}
if(student[0].all<student[1].all)
{
temp=student[0];
student[0]=student[1];
student[1]=temp;
}
}
for(l=0;l<3;l++)
{
printf("%d %d\n",student[l].num,student[l].all);
}
} | 14 |
6,922 | int main(){
struct student{
int num;
int chs;
int math;
};
struct student s[100000];
struct student s1[2]={{0,0,0},{0,0,0}};
int n,i,t,j,a[100000],k=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&s[i].num,&s[i].chs,&s[i].math);
a[i]=s[i].chs+s[i].math;
}
for(i=0;i<3;i++){
for(j=0;j<n-1-i;j++){
if(a[j]>a[j+1]){
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(i=n-1;i>n-4;i--){
for(j=0;j<n;j++){
if(a[i]==s[j].chs+s[j].math&&s[j].num!=s1[0].num&&s[j].num!=s1[1].num){
printf("%d %d\n",s[j].num,s[j].chs+s[j].math);
s1[k]=s[j];
k++;
if(k==3){
goto end;
}
}
}
}
end:
return 0;
} | 14 |
6,923 | struct stu
{
int id;
int c;
int m;
int t;
};
int main()
{
int n,i,j,K;
struct stu a[4]={0};
struct stu b[4]={0};
struct stu temp={0};
scanf("%d",&n);
for(i=0;i<=(n-1);i++)
{
if(i<=2)
{scanf("%d%d%d",&a[i].id,&a[i].c,&a[i].m);
a[i].t=a[i].c+a[i].m;
b[i]=a[i];}
else
{
scanf("%d%d%d",&a[3].id,&a[3].c,&a[3].m);
a[3].t=a[3].c+a[3].m;
b[3]=a[3];
//a[3]="\0";
for(K=0;K<=3;K++)
{
for(j=0;j<=3;j++)
{
if(b[j].t<b[j+1].t)
{ temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
}
}
for(i=0;i<=2;i++)
{
printf("%d %d\n",b[i].id,b[i].t);
}
} | 14 |
6,924 | int main()
{
int i,t=0,c=1,d=1,n,p=0,q=0,r=0,*b;
struct pp
{
int x;
int y;
int z;
}*s;
scanf("%d",&n);
b=(int*)malloc(sizeof(int)*n);
s=(struct pp*)malloc(sizeof(int)*3*n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].z);
b[i]=((s[i].y)+(s[i].z));
}
for(i=0;i<n;i++)
{
if(b[i]>t)
{
t=b[i];
p=i;
}
}
for(i=0;i<n;i++)
{
{
if((b[i]>c)&&(i!=p))
{c=b[i];
q=i;}
}
}
for(i=0;i<n;i++)
{
{
if((b[i]>d)&&(i!=p)&&(i!=q))
{d=b[i];
r=i;}
}
}
printf("%d %d\n",s[p].x,b[p]);
printf("%d %d\n",s[q].x,b[q]);
printf("%d %d\n",s[r].x,b[r]);
return 0;
}
| 14 |
6,925 | void main()
{
struct student
{
long int num;
int score1;
int score2;
};
struct student stu[100000];
long int n;
int i,j,k,m,a=0,b=0,c=0,A,B,C;
A=B=C=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].score1,&stu[i].score2);
k=stu[i].score1+stu[i].score2;
if(k>c)
{
c=k;
C=stu[i].num;
}
if(c>b)
{
m=c;
c=b;
b=m;
m=C;
C=B;
B=m;
}
if(b>a)
{
m=b;
b=a;
a=m;
m=B;
B=A;
A=m;
}
}
printf("%d %d\n%d %d\n%d %d",A,a,B,b,C,c);
}
| 14 |
6,926 | int n;
struct stu
{
int xh;
int yw;
int sx;
int all;
struct stu*next;
};
struct stu *a,*b,*c,q,t,r;
struct stu*creat()
{
struct stu *head;
struct stu *p1,*p2;
int i;
p1=p2=(struct stu*)malloc(sizeof(struct stu));
scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
p1->all=p1->yw+p1->sx;
head=p1;
a=b=c=head;
for(i=1;i<n;i++)
{
p2->next=p1;
p2=p1;
p1=(struct stu*)malloc(sizeof(struct stu));
scanf("%d%d%d",&p1->xh,&p1->yw,&p1->sx);
p1->all=p1->yw+p1->sx;
if(p1->all>a->all)
{
c=b;
b=a;
a=p1;
}
else
if(p1->all>b->all)
{
c=b;
b=p1;
}
else
{
if(p1->all>c->all)
c=p1;
}
}p2->next=NULL;
return head;
}
void main()
{
struct stu *p;
a=&q;b=&t;c=&r;
scanf("%d",&n);
p=creat();
printf("%d %d\n%d %d\n%d %d\n",a->xh,a->all,b->xh,b->all,c->xh,c->all);
}
| 14 |
6,927 | struct w
{int id;
int ch;
int ma;
int sum;
struct w *next;
struct w *pre;
}*head,*p1,*p2;
int i,n,k=1,max,s=0;
struct w *make(void)
{
head=null;
scanf("%d",&n);
p1=p2=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
for(k=1;k<n;k++)
{
if(k==1){head=p1;p1->pre=null;}
else {p2->next=p1;p1->pre=p2;}
p2=p1;
p1=(struct w *)malloc(len);
scanf("%d %d %d",&p1->id,&p1->ch,&p1->ma);
}
p2->next=p1;
p1->next=head;
return head;
}
void main()
{
head=make();max=0;
while(s<3)
{
max=0;
for(i=1;i<=n;i++)
{
if(i==n)p1=null;
else
{
p1->sum=p1->ch+p1->ma;
p1=p1->next;
}
}
p1=head;
for(i=1;i<=n;i++)
{
if((p1->sum)>max)
max=p1->sum;
p1=p1->next;
}
p1=head;
for(i=1;i<=n;i++)
{
p2=p1;
p1=p1->next;
if(p2->ch+p2->ma==max)
{
printf("%d %d\n",p2->id,p2->sum);
if(p2==head)
{
head=p2->next;
p2=head;
}
else
{
p2=p2->pre;
p1=p1->next;
p2->next=p1;
}
break;
}
}
s++;
}
}
| 14 |
6,928 | struct student
{
long int ID;
int math;
int chinese;
int add;
}stu[100000];
main()
{
long int n;
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].ID,&stu[i].math,&stu[i].chinese);
stu[i].add=stu[i].math+stu[i].chinese;
}
for(i=0;i<3;i++)
{
for(j=i+1;j<n;j++)
{
if(stu[i].add<stu[j].add)
{
int t=stu[i].add;
stu[i].add=stu[j].add;
stu[j].add=t;
long int m=stu[i].ID;
stu[i].ID=stu[j].ID;
stu[j].ID=m;
}
}
printf("%d %d\n",stu[i].ID,stu[i].add);
}
getchar();
getchar();
} | 14 |
6,929 | struct stu
{
float num;
float chi,mat,total;
struct stu *next;
};
struct stu *creat(int n)
{
int i;
struct stu *head,*p1,*p2;
for(i=0;i<n;i++)
{
p1=(struct stu*)malloc(sizeof(struct stu));
scanf("%f %f %f",&p1->num,&p1->chi,&p1->mat);
p1->total=p1->chi+p1->mat;
if (i==0)
{head=p2=p1;}
else
{p2->next=p1;p2=p1;}
}
p2->next=0;
return(head);
}
void main()
{
int n,i,j;
float max;
struct stu *head,*maxi,*p;
scanf("%d",&n);
head=creat(n);
for(i=0;i<3;i++)
{
p=head;maxi=head;
max=head->total;
for(j=0;j<n-1;j++)
{
p=p->next;
if(p->total>max)
{max=p->total;maxi=p;}
}
printf("%g %g\n",maxi->num,maxi->total);
maxi->total=0;
}
}
| 14 |
6,930 | struct student
{
int num,a,b;
struct student *next;
};
int n;
struct student *create(void)
{
struct student *head;
struct student *p1,*p2;
int i;
i=1;
p1=p2=(struct student*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->a,&p1->b);
head=NULL;
while(1)
{
if(i==1)
head=p1;
else
p2->next=p1;
p2=p1;
if(i==n)
break;
p1=(struct student*)malloc(LEN);
scanf("%d %d %d",&p1->num,&p1->a,&p1->b);
i++;
}
p2->next=NULL;
return(head);
}
void main()
{
struct student *head,*h,*x;
scanf("%d",&n);
head=create();
h=x=head;
int (*p)[2],m,j,s,i;
p=(int(*)[2])calloc(100000,2*sizeof(int));
for(i=0;i<n;i++)
{
p[i][1]=h->a+h->b;
p[i][0]=h->num;
h=x->next;
x=h;
}
for(i=0;i<3;i++)
for(j=0;j<n-i-1;j++)
if(p[j][1]>=p[j+1][1])
{
m=p[j][1];
p[j][1]=p[j+1][1];
p[j+1][1]=m;
s=p[j][0];
p[j][0]=p[j+1][0];
p[j+1][0]=s;
}
for(i=n-1;i>n-4;i--)
printf("%d %d\n",p[i][0],p[i][1]);
} | 14 |
6,931 | struct student
{
int number;
int score1;
int score2;
};
struct student stu[100000];
int main()
{
int n,i,first=0,second=0,third=0,a[100000];
scanf("%d\n",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].number,&stu[i].score1,&stu[i].score2);
a[i]=stu[i].score1+stu[i].score2;
}
for(i=0;i<n-1;i++)
{
if(a[first]<a[i])
{
third=second;
second=first;
first=i;
}
else if(a[second]<a[i])
{
third=second;
second=i;
}
else if(a[third]<a[i])
{
third=i;
}
}
printf("%d %d\n%d %d\n%d %d\n",stu[first].number,a[first],stu[second].number,a[second],stu[third].number,a[third]);
return(0);
} | 14 |
6,932 | int x[100000],y[100000],z[100000],s[100000],b[100000];
int main(int argc, char* argv[])
{
int n;
scanf("%d",&n);
int i,j,t,m1,m2;
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&x[i],&y[i],&z[i]);
s[i]=y[i]+z[i];
b[i]=s[i];
}
for(i=1;i<4;i++)
{
for(j=i+1;j<=n;j++)
{
if(s[i]<s[j])
{
t=s[i];
s[i]=s[j];
s[j]=t;
}
}
}
for(i=1;i<=n;i++)
{
if(s[1]==b[i])
{
m1=i;
printf("%d %d\n",x[i],b[i]);
break;
}
}
for(i=1;i<=n;i++)
{
if(s[2]==b[i]&&i!=m1)
{
m2=i;
printf("%d %d\n",x[i],b[i]);
break;
}
}
for(i=1;i<=n;i++)
{
if(s[3]==b[i]&&i!=m1&&i!=m2)
{
printf("%d %d\n",x[i],b[i]);
break;
}
}
return 0;
}
| 14 |
6,933 |
struct student {
int id;
int chinese;
int math;
int total;
};
int main() {
int i, num;
struct student stu[100000];
int max_0 = 0, max_1 = 0, max_2 = 0;
int max_0_id, max_1_id, max_2_id;
scanf("%d", &num);
for (i = 0; i < num; ++i) {
scanf("%d %d %d", &(stu[i].id), &(stu[i].chinese), &(stu[i].math));
stu[i].total = stu[i].chinese + stu[i].math;
if (stu[i].total > max_0) {
// update second and third highest
max_2 = max_1;
max_2_id = max_1_id;
max_1 = max_0;
max_1_id = max_0_id;
max_0 = stu[i].total;
max_0_id = stu[i].id;
}
else if (stu[i].total > max_1) {
// update third highest
max_2 = max_1;
max_2_id = max_1_id;
max_1 = stu[i].total;
max_1_id = stu[i].id;
}
else if (stu[i].total > max_2) {
max_2 = stu[i].total;
max_2_id = stu[i].id;
}
}
printf("%d %d\n", max_0_id, max_0);
printf("%d %d\n", max_1_id, max_1);
printf("%d %d\n", max_2_id, max_2);
return 0;
}
| 14 |
6,934 | struct Stu{
int stuID;
int mark;
}stu[3]={0};
int compare(const void *p1,const void *p2)
{
struct Stu *a;
struct Stu *b;
a=(struct Stu*)p1;
b=(struct Stu*)p2;
if(a->mark>b->mark) return -1;
if(a->mark<b->mark) return 1;
if(a->mark==b->mark) return 0;
}
void main(){
int n,i;
int ID,chi,math;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&ID,&chi,&math);
if(chi+math>stu[2].mark) {
stu[2].mark=chi+math;
stu[2].stuID=ID;
}
qsort(stu,3,sizeof(struct Stu),compare);
}
for(i=0;i<3;i++)
printf("%d %d\n",stu[i].stuID,stu[i].mark);
}
| 14 |
6,935 | struct info
{
char num[10];
int chn;
int math;
struct info *next;
};
int n,all;
struct info *setup(void)
{
struct info *head,*p1,*p2;
n=0;
while(n<all)
{
p1=(struct info*)malloc(sizeof(struct info));
scanf("%s %d %d",p1->num,&p1->chn,&p1->math);
n+=1;
if(n==1)head=p1;
else p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
void main()
{
struct info *p;
int i,first=0,second=0,third=0;
char fnum[10],snum[10],tnum[10];
scanf("%d",&all);
p=setup();
do
{
if(TOTAL>first)
{
third=second;
second=first;
first=TOTAL;
strcpy(tnum,"");
strcat(tnum,snum);
strcpy(snum,"");
strcat(snum,fnum);
strcpy(fnum,"");
strcat(fnum,p->num);
}
else if(TOTAL>second)
{
third=second;
second=TOTAL;
strcpy(tnum,"");
strcat(tnum,snum);
strcpy(snum,"");
strcat(snum,p->num);
}
else if(TOTAL>third)
{
third=TOTAL;
strcpy(tnum,"");
strcat(tnum,p->num);
}
p=p->next;
}while(p!=NULL);
printf("%s %d\n%s %d\n%s %d\n",fnum,first,snum,second,tnum,third);
} | 14 |
6,936 | struct student
{
int num;
int ch;
int math;
int total;
struct student *next;
};
int n;
int t;
struct student *creat(void)
{
struct student *head;
struct student *p1,*p2;
int i;
scanf("%d",&n);
head=p1=p2=(struct student*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
p1->total=p1->ch+p1->math;
for (i=2;i<=n;i++)
{
p1=(struct student*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->ch,&p1->math);
p1->total=p1->ch+p1->math;
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
void print(struct student *head)
{
struct student *p;
int max;
p=head;
max=p->total;
p=p->next;
while(p->next!=NULL)
{
if(p->total>max)
{
max=p->total;
t=p->num;
}
p=p->next;
}
printf("%d %d\n",t,max);
}
struct student *del(struct student *head, int a)
{
struct student *p1,*p2;
p1=head;
while (a!=p1->num&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(p1==head)
{
head=p1->next;
}
else
{
p2->next=p1->next;
}
return(head);
}
void main()
{
struct student *head1,*head2,*head3;
head1=creat();
print(head1);
head2=del(head1,t);
print(head2);
head3=del(head2,t);
print(head3);
}
| 14 |
6,937 |
struct student
{
int id;
int math;
int chinese;
int sum;
}stu[100000];
int main(int argc, char* argv[])
{
int i , n ;
int max1=0,max2=0,max3=0;
int maxid1=0,maxid2=0,maxid3=0;
scanf("%d", &n );
for ( i = 0 ; i < n ; i ++ )
{
scanf("%d %d %d", &stu[i].id , &stu[i].chinese ,&stu[i].math );
stu[i].sum = stu[i].math + stu[i].chinese;
if ( stu[i].sum > max1 )
{
max3 = max2 ;
max2 = max1 ;
max1 = stu[i].sum ;
maxid3 = maxid2 ;
maxid2 = maxid1 ;
maxid1 = stu[i].id;
}
else if ( stu[i].sum > max2 )
{
max3 = max2 ;
max2 = stu[i].sum ;
maxid3 = maxid2 ;
maxid2 = stu[i].id ;
}
else if ( stu[i].sum > max3 )
{
max3 = stu[i].sum ;
maxid3 = stu[i].id ;
}
}
printf("%d %d\n%d %d\n%d %d" , maxid1,max1,maxid2,max2,maxid3,max3);
return 0;
}
| 14 |
6,938 | struct stu
{int n;
int a;
int m;
struct stu *next;
};
int n,l;
struct stu *creat(void)
{
struct stu *head;
struct stu *p,*q;
n=0;
p=q=(struct stu *)malloc(Len);
scanf("%d %d %d",&p->n,&p->a,&p->m);
head=Null;
for(;n<l-1;)
{
n++;
if(n==1) head=p;
else q->next=p;
q=p;
p=(struct stu *)malloc(Len);
scanf("%d %d %d",&p->n,&p->a,&p->m);
}
q->next=Null;
return(head);
}
void main()
{
int s=0;
struct stu *p,*q,*c,*d,*head;
scanf("%d",&l);
head=p=q=creat();
for(;;)
{
if((p->m+p->a)>s)
{
s=p->m+p->a;
c=p;
d=q;
}
q=p;
p=q->next;
if(p->next==Null) break;
}
printf("%d %d\n",c->n,s);
if(d==head)
head=((c->next)->next);
else
d->next=c->next;
p=q=head;
s=0;
for(;;)
{
if((p->m+p->a)>s)
{
s=p->m+p->a;
c=p;
d=q;
}
q=p;
p=p->next;
if(p->next==Null) break;
}
printf("%d %d\n",c->n,s);
if(d==head)
head=p=q=((c->next)->next);
else
d->next=c->next;
p=q=head;
s=0;
for(;;)
{
if((p->m+p->a)>s)
{
s=p->m+p->a;
c=p;
d=q;
}
q=p;
p=p->next;
if(p->next==Null) break;
}
printf("%d %d\n",c->n,s);
}
| 14 |
6,939 | struct student
{ int ID;
int ch;
int ma;
};
void main()
{ struct student re[N];
int n;
int i=0,j=0,rec;
int total[N];
scanf("%d",&n);
for(i=0;i<n;i++)
{ scanf("%d%d%d",&re[i].ID,&re[i].ch,&re[i].ma);
total[i]=re[i].ch+re[i].ma;
}
int max=total[0];
for(i=0;i<n;i++)
{ if(max<total[i])
{ max=total[i];
rec=i;
}
if(i==n-1)
{ printf("%d %d\n",re[rec].ID,total[rec]);
total[rec]=0;
i=0;
max=total[0];
j++;
}
if(j==3)
break;
}
}
| 14 |
6,940 | int main()
{
int n,i;
int o=0,oz,t=0,tz,th=0;
scanf("%d",&n);
struct{
int h,z;
}s[100000];
for(i=0;i<n;i++)
{
int h0,x0,y0;
scanf("%d%d%d",&h0,&x0,&y0);
s[i].h=h0;
s[i].z=x0+y0;
}
for(i=0;i<n;i++)
if(s[i].z>o)
o=s[i].z;
for(i=0;i<n;i++)
if(s[i].z==o)
{
oz=i;
printf("%d %d\n",s[i].h,s[i].z);
break;
}
for(i=0;i<n;i++)
if((i!=oz)&&(s[i].z>t))
t=s[i].z;
for(i=0;i<n;i++)
if((i!=oz)&&(s[i].z==t))
{
tz=i;
printf("%d %d\n",s[i].h,s[i].z);
break;
}
for(i=0;i<n;i++)
if((i!=oz)&&(i!=tz)&&(s[i].z>th))
th=s[i].z;
for(i=0;i<n;i++)
if((i!=oz)&&(i!=tz)&&(s[i].z==th))
{
printf("%d %d\n",s[i].h,s[i].z);
break;
}
return 0;
}
| 14 |
6,941 | int main(){
struct student{
int stuno;
int score1;
int score2;
int score0;
};
int n,i,j,temp;
cin>>n;
struct student num[n];
for(i=0;i<n;i++){
cin>>num[i].stuno;
cin>>num[i].score1;
cin>>num[i].score2;
num[i].score0=num[i].score1+num[i].score2;
}
for(i=0;i<3;i++)
for(j=i+1;j<n;j++)
if(num[i].score0<num[j].score0){
temp=num[i].score0;
num[i].score0=num[j].score0;
num[j].score0=temp;
temp=num[i].stuno;
num[i].stuno=num[j].stuno;
num[j].stuno=temp;
}
for(i=0;i<3&&i<n;i++)
cout<<num[i].stuno<<" "<<num[i].score0<<endl;
return 0;
}
| 14 |
6,942 | void main()
{
int n,i,j,max,k;
struct stu
{
int num;
int chinese;
int maths;
int all;
}stu[100000];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&stu[i].num,&stu[i].chinese,&stu[i].maths);
for(i=0;i<n;i++)
stu[i].all=stu[i].chinese+stu[i].maths;
for(k=0;k<3;k++)
{
max=stu[0].all;
for(i=0;i<n;i++)
{
if(stu[i].all>max)
{
max=stu[i].all;
j=i;
}
}
printf("%d %d\n",stu[j].num,stu[j].all);
stu[j].all=0;
}
}
| 14 |
6,943 |
struct student
{
long int id;
int chinese;
int math;
};
main()
{
long int i,maxi1,maxi2,maxi3,num;
scanf("%d",&num);
struct student a[num];
for (i=0;i<num;i++)
scanf("%d %d %d",&a[i].id,&a[i].chinese,&a[i].math);
int maxpt1=0,maxpt2=0,maxpt3=0;
for (i=0;i<num;i++)
{
if (maxpt1<a[i].chinese+a[i].math)
{
maxpt3=maxpt2;
maxpt2=maxpt1;
maxpt1=a[i].chinese+a[i].math;
maxi3=maxi2;
maxi2=maxi1;
maxi1=a[i].id;
}
else if (maxpt2<a[i].chinese+a[i].math)
{
maxpt3=maxpt2;
maxpt2=a[i].chinese+a[i].math;
maxi3=maxi2;
maxi2=a[i].id;
}
else if (maxpt3<a[i].chinese+a[i].math)
{
maxpt3=a[i].chinese+a[i].math;
maxi3=a[i].id;
}
}
printf("%d %d\n%d %d\n%d %d",maxi1,maxpt1,maxi2,maxpt2,maxi3,maxpt3);
}
| 14 |
6,944 |
int main()
{
struct score
{
int n;
int a;
int b;
int c;
}score[5];
int i,m;
scanf("%d",&m);
score[1].n=0;
score[1].c=0;
score[2].n=0;
score[2].c=0;
score[3].n=0;
score[3].c=0;
for (i=0;i<m;i++)
{
scanf("%d%d%d",&score[4].n,&score[4].a,&score[4].b);
score[4].c=score[4].a+score[4].b;
if (score[4].c>score[1].c)
{
score[3]=score[2];
score[2]=score[1];
score[1]=score[4];
}
else if (score[4].c>score[2].c)
{
score[3]=score[2];
score[2]=score[4];
}
else if (score[4].c>score[3].c)
score[3]=score[4];
}
printf("%d %d\n%d %d\n%d %d\n",score[1].n,score[1].c,score[2].n,score[2].c,score[3].n,score[3].c);
return 0;
} | 14 |
6,945 | void main()
{
struct student
{
int ID;
int chinese;
int math;
int total;
}stu1,stu2,stu3,temp;
int i,n;
stu1.total=0;
stu2.total=0;
stu3.total=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&temp.ID,&temp.chinese,&temp.math);
temp.total=temp.chinese+temp.math;
if(temp.total>stu1.total)
{
stu3=stu2;
stu2=stu1;
stu1=temp;
}
else if(temp.total<=stu1.total&&temp.total>stu2.total)
{
stu3=stu2;
stu2=temp;
}
else if(temp.total<=stu2.total&&temp.total>stu3.total)stu3=temp;
}
printf("%d %d\n",stu1.ID,stu1.total);
printf("%d %d\n",stu2.ID,stu2.total);
printf("%d %d\n",stu3.ID,stu3.total);
} | 14 |
6,946 | struct Student
{
int id;
int c;
int m;
int sum;
};
void main()
{
struct Student temp,s1,s2,s3;
int i,n;
s1.sum=s2.sum=s3.sum=-1;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&temp.id,&temp.c,&temp.m);
temp.sum=temp.c+temp.m;
if(temp.sum>s1.sum)
{
s3=s2;
s2=s1;
s1=temp;
}
else if (temp.sum>s2.sum)
{
s3=s2;
s2=temp;
}
else if(temp.sum>s3.sum)
{
s3=temp;
}
}
printf("%d %d\n%d %d\n%d %d\n",s1.id,s1.sum,s2.id,s2.sum,s3.id,s3.sum);
}
| 14 |
6,947 |
struct stu1
{
long num;
int score1;
int score2;
struct stu1 *next;
};
struct stu1 *creat(void)
{
int n,i=1;
struct stu1 *h;
struct stu1 *q1,*q2;
scanf("%d",&n);
q2=q1=(struct stu1 *)malloc(LEN1);
h=NULL;
while(i<=n)
{
scanf("%ld %d %d",&q1->num,&q1->score1,&q1->score2);
if(i==1){h=q1;}
else{q2=q1;}
if(i!=n)
{
q1=q2->next=(struct stu1 *)malloc(LEN1);
}
else {q1->next=NULL;}
i++;
}
return(h);
}
struct stu1 *turn(struct stu1 *h)
{
int t=1;
struct stu1 *p1,*p2;
int m,n,w;
for(p1=h,t=1;p1->next!=NULL,t<=3;p1=p1->next,t++)
{
p2=p1->next;
while(p2!=NULL)
{
if((p1->score1+p1->score2)<(p2->score1+p2->score2))
{
m=p1->num;n=p1->score1;w=p1->score2;
p1->num=p2->num;p1->score1=p2->score1;p1->score2=p2->score2;
p2->num=m;p2->score1=n;p2->score2=w;
}
p2=p2->next;
}
printf("%ld %d\n",p1->num,(p1->score1+p1->score2));
}
return(h);
}
/*void print(struct stu1 *h)
{
int t=1;
struct stu1 *p;
p=h;
for(t=1;t<=3;t++)
{
printf("%ld %d\n",p->num,(p->score1+p->score2));
p=p->next;
}
}*/
void main()
{
struct stu1 *ip/*,*is*/;
ip=creat();
/*is=*/turn(ip);
/*print(is);*/
} | 14 |
6,948 | struct student
{
long a;
int x;
int y;
};
struct student stu[100000];
main()
{
long n,i,j,p;
int m;
scanf("%ld",&n);
int g[100000];
for(i=0;i<n;i++)
{
scanf("%ld %d %d",&stu[i].a,&stu[i].x,&stu[i].y);
g[i]=stu[i].x+stu[i].y;
}
for(i=1;i<4;i++)
for(j=n-1;j>=i;j--)
if(g[j-1]<g[j])
{
m=g[j-1];g[j-1]=g[j];g[j]=m;
p=stu[j-1].a;stu[j-1].a=stu[j].a;stu[j].a=p;
}
for(i=0;i<3;i++)
printf("%ld %d\n",stu[i].a,g[i]);
}
| 14 |
6,949 | struct student
{
char num[30];
float chi;
float mat;
float tot;
struct student *next;
};
struct student * creat(struct student *head,struct student *stud)
{
struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{while((p0->tot<=p1->tot)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if(p0->tot>=p1->tot)
{if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;}
else
{p1->next=p0;p0->next=NULL;}
}
return(head);
}
struct student * compare(struct student *head,struct student *stud)
{
struct student *p0,*p1,*p2;
int i;
p1=head;
p0=stud;
while((p0->tot<=p1->tot)&&(p1->next!=NULL))
{p2=p1;p1=p1->next;}
if((p0->tot>p1->tot)||((p0->tot=p1->tot)&&(p1->next!=NULL)))
{
if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;
p1=head;
for(i=0;i<2;i++)
{p1=p1->next;}
p1->next=NULL;
}
return(head);
}
void print(struct student * head)
{
struct student *p;
int i;
p=head;
for(i=0;i<3;i++)
{
printf("%s %g\n",p->num,p->tot);
p=p->next;
}
}
void main()
{
struct student *head;
struct student *stu;
int n,i;
head=NULL;
scanf("%d",&n);
for(i=0;i<3;i++)
{ stu=(struct student *)malloc(LEN);
scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
stu->tot=stu->chi+stu->mat;
head=creat(head,stu);
}
for(i=3;i<n;i++)
{
stu=(struct student *)malloc(LEN);
scanf("%s %f %f",&stu->num,&stu->chi,&stu->mat);
stu->tot=stu->chi+stu->mat;
head=compare(head,stu);
}
print(head);
}
| 14 |
6,950 | int main()
{
struct student{int id,chin,math,z;}p[100000];
int id,math,chin,z,i,n,f,s,t,id1,id2,id3;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&id,&chin,&math);
p[i].id=id;
p[i].math=math;
p[i].chin=chin;
}
for(i=0;i<n;i++)
{
id=p[i].id;
math=p[i].math;
chin=p[i].chin;
z=math+chin;
if(i==0)
{
f=s=t=z;
id1=id2=id3=id;
}
else if(i==1)
{
if(z>f)
{
t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
}
else
{
t=s=z;id2=id3=id;
}
}
else
{
if(z>f)
{
t=s;id3=id2;s=f;id2=id1;f=z;id1=id;
}
else if(z>s)
{
t=s;id3=id2;s=z;id2=id;
}
else if(z>t)
{
t=z;id3=id;
}
}
}
printf("%d %d\n",id1,f);
printf("%d %d\n",id2,s);
printf("%d %d\n",id3,t);
return 0;
}
| 14 |
6,951 | int main(int argc, char* argv[])
{
int n;
scanf("%d",&n);
struct stu{
int id;
int x,y;
}stu[100000];
int no1=0;
int no2=0;
int no3=0;
int i;
int N1,N2,N3;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&stu[i].id,&stu[i].x,&stu[i].y);
}
for(i=0;i<n;i++)
{
if((stu[i].x+stu[i].y)>no1){no2=no1;no1=(stu[i].x+stu[i].y);N2=N1;N1=i;}
else if((stu[i].x+stu[i].y)>no2){no3=no2;no2=(stu[i].x+stu[i].y);N3=N2;N2=i;}
else if((stu[i].x+stu[i].y)>no3){no3=(stu[i].x+stu[i].y);N3=i;}
}
printf("%d %d\n%d %d\n%d %d",stu[N1].id,(stu[N1].x+stu[N1].y),stu[N2].id,(stu[N2].x+stu[N2].y),stu[N3].id,(stu[N3].x+stu[N3].y));
return 0;
}
| 14 |
6,952 | struct student
{
int num;
float yuwen;
float shuxue;
float total;
}stu[100000];
void main()
{
int i,n,j;
struct student *p;
p=&stu[0];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%f%f",&(p+i)->num,&(p+i)->yuwen,&(p+i)->shuxue);
(p+i)->total=(p+i)->shuxue+(p+i)->yuwen;
}
for(i=0;i<3;i++)
for(j=0;j<n-1-i;j++)
{
if((*(p+j)).total>=(*(p+j+1)).total)
{
struct student temp;
temp=*(p+j+1);
*(p+j+1)=*(p+j);
*(p+j)=temp;
}
}
if(n>2)
for(i=1;i<4;i++)
printf("%d %g\n",(*(p+n-i)).num,(*(p+n-i)).total);
else if(n=2)
printf("%d %g\n%d %g\n",(*(p+1)).num,(*(p+1)).total,(*p).num,(*p).total);
}
| 14 |
6,953 | int main()
{
int a[99999],b[99999],c[99999],d[99999];
int i,n,sum,s;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
d[i]=c[i]+b[i];
}
for (i=0;i<n;i++)
{
if (d[i]>=d[i+1]){
sum=d[i];
d[i]=d[i+1];
d[i+1]=sum;
s=a[i];
a[i]=a[i+1];
a[i+1]=s;
}
}
for (i=0;i<n-1;i++)
{
if (d[i]>=d[i+1]){
sum=d[i];
d[i]=d[i+1];
d[i+1]=sum;
s=a[i];
a[i]=a[i+1];
a[i+1]=s;
}
}
for (i=0;i<n-2;i++)
{
if (d[i]>=d[i+1]){
sum=d[i];
d[i]=d[i+1];
d[i+1]=sum;
s=a[i];
a[i]=a[i+1];
a[i+1]=s;
}
}
printf("%d %d\n%d %d\n%d %d",a[n],d[n],a[n-1],d[n-1],a[n-2],d[n-2]);
return 0;
}
| 14 |
6,954 |
struct stu
{
int num;
int a;
int b;
int total;
int flag;
struct stu *next;
};
void main()
{
struct stu *p,*head;
struct stu *p1,*p2,*pmax;
int N,i;
int max;
scanf("%d",&N);
//??
p1=p2=(struct stu*)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->a,&p1->b);
p1->total=p1->a+p1->b;
p1->flag=0;
p1->next=NULL;
head=p1;
for(i=0;i<N-1;i++)
{
p2=p1;
p1=(struct stu *)malloc(LEN);
scanf("%d%d%d",&p1->num,&p1->a,&p1->b);
p1->total=p1->a+p1->b;
p1->flag=0;
p1->next=NULL;
p2->next=p1;
}
for(i=0;i<3;i++)
{
for(p=head,max=0;p!=NULL;p=p->next)
if(max<p->total&&p->flag==0)
{
max=p->total;
pmax=p;
}
pmax->flag=1;
printf("%d %d\n",pmax->num,pmax->total);
}
/* p=head;
do
{
printf("%d*,",p->num);
p=p->next;
}while(p!=NULL);*/
// for(i=0;i<3;i++)
// printf("%d %d\n",pmax[i]->num,pmax[i]->total);
} | 14 |
6,955 | int main()
{
struct gpa
{
int num;
int math;
int chin;
int total;
}
STUDENT_NUM[100000], first,second,third;
int num,math,chin;
long n,i;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&num);
scanf("%d",&math);
scanf("%d",&chin);
STUDENT_NUM[i].num=num;
STUDENT_NUM[i].math=math;
STUDENT_NUM[i].chin=chin;
STUDENT_NUM[i].total=math+chin;
}
first.num=0;
first.total=0;
second.num=0;
second.total=0;
third.num=0;
third.total=0;
for(i=1;i<=n;i++)
{
if(STUDENT_NUM[i].total>first.total)
{
first.num=STUDENT_NUM[i].num;
first.total=STUDENT_NUM[i].total;
}
}
for(i=1;i<=n;i++)
{
if(STUDENT_NUM[i].num==first.num)
{STUDENT_NUM[i].total=0;}
}
for(i=1;i<=n;i++)
{
if(STUDENT_NUM[i].total>second.total)
{
second.num=STUDENT_NUM[i].num;
second.total=STUDENT_NUM[i].total;
}
}
for(i=1;i<=n;i++)
{
if (STUDENT_NUM[i].num==second.num)
{STUDENT_NUM[i].total=0;}
}
for(i=1;i<=n;i++)
{
if(STUDENT_NUM[i].total>third.total)
{
third.num=STUDENT_NUM[i].num;
third.total=STUDENT_NUM[i].total;
}
}
printf("%d %d\n",first.num,first.total);
printf("%d %d\n",second.num,second.total);
printf("%d %d\n",third.num,third.total);
getchar();
getchar();
getchar();
getchar();
}
| 14 |
6,956 | struct stu
{
long xh;
int yw;
int sx;
int zh;
struct stu *next;
};
struct stu *scan()
{
long n;
long num=0;
struct stu *head,*p1,*p2;
p1=p2=(struct stu *)malloc(sizeof (struct stu));
scanf("%ld",&n);
// head=0;
head=p1;
while(num<n)
{
scanf("%ld",&p1->xh);
scanf("%d",&p1->yw);
scanf("%d",&p1->sx);
p1->zh=p1->yw+p1->sx;
p2=p1;
p1=(struct stu *)malloc(sizeof (struct stu));
p2->next=p1;
p1->next=0;
num++;
}
return(head);
}
struct stu *del(struct stu *head,int max)
{
struct stu *p1,*p2;
p1=head;
while(max!=p1->zh&&p1->next!=0)
{
p2=p1;
p1=p1->next;
}
if(max==p1->zh)
{
if(p1==head)
{
head=p1->next;
}
else
{
p2->next=p1->next;
}
}
return (head);
}
void print(struct stu *head)
{
struct stu *p,*p1,*p2,*p3,*w;
int max=0,num=0;
while(num<3)
{
for(p=head;p!=0;p=p->next)
{
if(p->zh>max)
{
max=p->zh;
w=p;
}
}
num++;
if(num==1)
{
p1=w;
head=del(head,max);
max=0;
}
if(num==2)
{
p2=w;
head=del(head,max);
max=0;
}
if(num==3)
{
p3=w;
}
}
printf("%ld %d\n%ld %d\n%ld %d\n",p1->xh,p1->zh,p2->xh,p2->zh,p3->xh,p3->zh);
}
void main()
{
struct stu *head;
head=scan();
print(head);
} | 14 |
6,957 | int k[99999];
int x[99999];
int main()
{
int n,i ,a,b,c,j,r,t,m=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&a,&b,&c);k[a-1]=b+c;x[i]=a;
}
for(j=n-1;j>=0;j--)
{
for(r=0;r<j;r++)
{
if(k[r]>=k[r+1])
{
t=k[r+1];
k[r+1]=k[r];
k[r]=t;
t=x[r+1];
x[r+1]=x[r];
x[r]=t;
}
} m++;
if(m>3) break;
}
printf("%d %d\n%d %d\n%d %d\n",x[n-1],k[n-1],x[n-2],k[n-2],x[n-3],k[n-3]);
return 0;
} | 14 |
6,958 | struct student
{
long num;
int chi;
int math;
int sum;
struct student *next;
};
long n;
void main()
{
struct student *creat();
struct student *head,*p,*q1,*q2,*q3;
int a;
scanf("%ld",&n);
head=creat();
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a)
{
a=p->sum;
q1=p;
}
p=p->next;
}
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a&&p!=q1)
{
a=p->sum;
q2=p;
}
p=p->next;
}
p=head;
a=0;
while(p!=NULL)
{
if(p->sum>a&&p!=q1&&p!=q2)
{
a=p->sum;
q3=p;
}
p=p->next;
}
printf("%d %d\n",q1->num,q1->sum);
printf("%d %d\n",q2->num,q2->sum);
printf("%d %d\n",q3->num,q3->sum);
}
struct student *creat()
{
struct student *head,*p1,*p2;
int i;
head=NULL;
p1=p2=(struct student *)malloc(LEN);
for(i=0;i<=n-1;i++)
{
scanf("%ld%d%d",&p1->num,&p1->chi,&p1->math);
p1->sum=p1->chi+p1->math;
if(i==0) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
}
p2->next=NULL;
return(head);
} | 14 |
6,959 |
void main()
{
struct student
{
int ID;
int math;
int chinese;
int sum;
};
int n,i,t,j;
scanf("%d",&n);
struct student stu[n];
for(i=0;i<n;i++)
scanf("%d %d %d",&stu[i].ID,&stu[i].math,&stu[i].chinese);
for(i=0;i<n;i++)
stu[i].sum=stu[i].math+stu[i].chinese;
for(i=0;i<3;i++)
{ for(j=i+1;j<n;j++)
if(stu[j].sum>stu[i].sum)
{t=stu[i].sum;stu[i].sum=stu[j].sum;stu[j].sum=t;
t=stu[i].ID;stu[i].ID=stu[j].ID;stu[j].ID=t;}
}
for(i=0;i<3;i++)
printf("%d %d\n",stu[i].ID,stu[i].sum);
}
| 14 |
6,960 | int main(int argc, char* argv[])
{
int N,i,n[num],c[num],m[num],sum[num];
int x1=0,x2=0,x3=0,y1=0,y2=0,y3=0;
scanf ("%d",&N);
for (i=0;i<N;i++)
{
scanf ("%d%d%d",&n[i],&c[i],&m[i]);
sum[i]=c[i]+m[i];
}
for (i=0;i<N;i++)
{
if (sum[i]>x1)
{
x1=sum[i];
y1=i;
}
}
for (i=0;i<N;i++)
{
if (sum[i]>x2&&sum[i]<=x1&&i!=y1)
{
x2=sum[i];
y2=i;
}
}
for (i=0;i<N;i++)
{
if (sum[i]>x3&&sum[i]<=x2&&i!=y1&&i!=y2)
{
x3=sum[i];
y3=i;
}
}
printf("%d %d\n%d %d\n%d %d\n",y1+1,x1,y2+1,x2,y3+1,x3);
return 0;
}
| 14 |
6,961 | void main()
{
struct student
{
int id;
int chi;
int mat;
int sum;
}stu[100000],t;
int i,j,n,student_num;
scanf("%d",&student_num);
n=student_num;
for(i=0;i<n;i++)
scanf("%d%d%d",&stu[i].id,&stu[i].chi,&stu[i].mat);
for(i=0;i<n;i++)
stu[i].sum=stu[i].chi+stu[i].mat;
for(i=0;i<n;i++)
if(stu[0].sum<stu[i].sum)
{t=stu[0];stu[0]=stu[i];stu[i]=t;}
for(i=1;i<n;i++)
if(stu[1].sum<stu[i].sum)
{t=stu[1];stu[1]=stu[i];stu[i]=t;}
for(i=2;i<n;i++)
if(stu[2].sum<stu[i].sum)
{t=stu[2];stu[2]=stu[i];stu[i]=t;}
for(i=0;i<3;i++)
printf("%d %d\n",stu[i].id,stu[i].sum);
}
| 14 |
6,962 | struct stu
{
int num;
int chinese;
int math;
int sum;
struct stu *next;
};
void main()
{
void max(struct stu*);
int n,i;
struct stu *p,*q,*head;
scanf("%d\n",&n);
head=(struct stu*)malloc(sizeof(struct stu));
p=(struct stu*)malloc(sizeof(struct stu));
head->next=p;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&p->num,&p->chinese,&p->math);
p->sum=p->chinese+p->math;
q=(struct stu*)malloc(sizeof(struct stu));
p->next=q;
p=q;
}
p->next=NULL;
max(head);
max(head);
max(head);
}
void max(struct stu*head)
{
struct stu *p,*k,*r,*q;
int max=0;
p=head;
while(p->next!=NULL)
{
r=p;
p=p->next;
if(p->sum>max) max=p->sum,k=r,q=p;
}
printf("%d %d\n",q->num,q->sum);
k->next=q->next;
free(q);
}
| 14 |
6,963 | struct a
{
char No[20];
int y;
int s;
struct a* next;
};
int n;
struct a* creat(void)
{
struct a *p1,*p2,*head;
int i;
scanf("%d\n",&n);
p1=p2=(struct a* )malloc(LEN);
head=NULL;
for(i=0;i<n;i++)
{
scanf("%s %d %d",p1->No,&p1->y,&p1->s);
if(i==0)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct a* )malloc(LEN);
}
p2->next=NULL;
return(head);
}
int main()
{
struct a *head,*p1,*p2,*p;
int i,j,k,m1,m2;
char r[10];
head=creat();
for(p1=head,j=0;p1!=NULL;p1=p1->next)
{
k=p1->y+p1->s;
if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
}
printf("%s %d\n",r,j);
for(p1=head;p1!=NULL;)
{
p2=p1;p1=p1->next;
if(p1==p){p2->next=p1->next;break;}
else if(p2==p){head=p1->next;break;}
}
for(p1=head,j=0;p1!=NULL;p1=p1->next)
{
k=p1->y+p1->s;
if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
}
printf("%s %d\n",r,j);
for(p1=head;p1!=NULL;)
{
p2=p1;p1=p1->next;
if(p1==p){p2->next=p1->next;break;}
else if(p2==p){head=p1->next;break;}
}
for(p1=head,j=0;p1!=NULL;p1=p1->next)
{
k=p1->y+p1->s;
if(k>j){p=p1;j=k;m1=p1->y;m2=p1->s;strcpy(r,p1->No);}
}
printf("%s %d",r,j);
} | 14 |
6,964 | void main()
{
struct student
{
int num;
int a;
int b;
}stu[100000];
int n,i,sum=0,max1=0,max2=0,max3=0,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].num,&stu[i].a,&stu[i].b);
sum=stu[i].a+stu[i].b;
if (sum>max1) {max3=max2;max2=max1;max1=sum;}
else if ((sum<max1)&&(sum>max2)){max3=max2;max2=sum;}
else if ((sum<max2)&&(sum>max3)){max3=sum;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if (sum==max1) {printf("%d %d\n",stu[i].num,max1);t++;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max2)&&(t<3)) {printf("%d %d\n",stu[i].num,max2);t++;}
}
for(i=0;i<n;i++)
{
sum=stu[i].a+stu[i].b;
if ((sum==max3)&&(t<3)) {printf("%d %d\n",stu[i].num,max3);t++;}
}
} | 14 |
6,965 | struct stud
{
int num;
int score,score1,score2;
struct stud *next;
}head,end;
void create(int n)
{
int i;
struct stud *p1,*p2;
head.next=NULL;
for (i=0;i<=n-1;i++)
{
p1=(struct stud *)malloc(sizeof(struct stud));
if (!i) head.next=p1;
else p2->next=p1;
scanf("%d",&p1->num);
scanf("%d",&p1->score1);
scanf("%d",&p1->score2);
p1->score=p1->score1+p1->score2;
p2=p1;
}
p2->next=&end;
}
void find()
{
struct stud *max1,*max2,*max3,*p1,*swap; //max1 is the max
max1=head.next;
max2=max1->next;
max3=max2->next;
p1=max3->next;
if ( max1->score < max2->score )
{
swap=max1;
max1=max2;
max2=swap;
}
if ( max2->score < max3->score )
{
swap=max2;
max2=max3;
max3=swap;
}
if ( max1->score < max2->score )
{
swap=max1;
max1=max2;
max2=swap;
}
while (p1!=&end)
{
if ( p1->score > max3->score ) max3=p1;
if ( max3->score > max2->score )
{
swap=max3;
max3=max2;
max2=swap;
}
if ( max2->score > max1->score )
{
swap=max1;
max1=max2;
max2=swap;
}
p1=p1->next;
}
printf("%d %d\n",max1->num,max1->score);
printf("%d %d\n",max2->num,max2->score);
printf("%d %d\n",max3->num,max3->score);
}
void main()
{
int n;
scanf("%d",&n);
create(n);
find();
}
| 14 |
6,966 | struct student
{
int num;
int all;
}person[99999];
int main()
{
int n,i,j,k,x,y;;
struct student temp1,temp2;
scanf("%d",&n);
for(i=2;i>=0;i--)
{
scanf("%d %d %d",&person[i].num,&x,&y);
person[i].all=x+y;
}
for(i=3;i<=n-1;i++)
{
scanf("%d %d %d",&person[i].num,&x,&y);
person[i].all=x+y;
k=person[i].all;
if(k>person[0].all) {temp1=person[0]; temp2=person[1]; person[0]=person[i];person[1]=temp1;person[2]=temp2; continue;}
if(k<=person[0].all&&k>person[1].all) {temp1=person[1];person[1]=person[i];person[2]=temp1; continue;}
if(k<=person[1].all&&k>person[2].all) {person[2]=person[i]; continue;}
if(k<person[2].all) {continue;}
}
printf("%d %d\n",person[0].num,person[0].all);
printf("%d %d\n",person[1].num,person[1].all);
printf("%d %d",person[2].num,person[2].all);
return 0;
} | 14 |
6,967 | struct stu
{
int id;
int verbal;
int math;
int sum;
};
int main()
{
struct stu *a,t;
int n,i,j;
scanf("%d",&n);
a=(struct stu *)malloc(n*sizeof(struct stu));
for (i=0;i<n;i++)
{
scanf("%d %d %d",&a[i].id,&a[i].verbal,&a[i].math);
a[i].sum=a[i].verbal+a[i].math;
}
for (j=0;j<3;j++)
for (i=n;i>j;i--)
if (a[i].sum>a[i-1].sum)
{
t=a[i];
a[i]=a[i-1];
a[i-1]=t;
}
for (i=0;i<3;i++)
printf("%d %d\n",a[i].id,a[i].sum);
return 0;
} | 14 |
6,968 | struct student
{
int number;
int math;
int chinese;
int total;
};
int main()
{
struct student a[100000];
int n,i,sf=0,ss=0,st=0,f,s,t;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d%d%d",&a[i].number,&a[i].math,&a[i].chinese);
a[i].total=a[i].math+a[i].chinese;
if (a[i].total>sf)
{
t=s; st=ss;
s=f; ss=sf;
f=i; sf=a[i].total;
}
else
if (a[i].total>ss)
{
t=s; st=ss;
s=i; ss=a[i].total;
}
else
if (a[i].total>st)
{
t=i; st=a[i].total;
}
}
printf("%d %d\n",f+1,sf);
printf("%d %d\n",s+1,ss);
printf("%d %d\n",t+1,st);
return 0;
}
| 14 |
6,969 | struct student
{
int num;
int chi;
int math;
int sum;
struct student *next;
};
struct student *creat(int n)
{
int i;
struct student *head,*p1,*p2;
p1=(struct student*)malloc(sizeof(struct student));
scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
p1->sum=p1->chi+p1->math;
head=p1;
p2=p1;
for(i=1;i<n;i++)
{
p1=(struct student*)malloc(sizeof(struct student));
scanf("%d %d %d",&p1->num,&p1->chi,&p1->math);
p1->sum=p1->chi+p1->math;
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
void main()
{
struct student *head,*p1;
struct student *max1,*max2,*max3;
int n,max;
scanf("%d",&n);
head=creat(n);
p1=head;
max=0;
while(p1!=NULL)
{
if(p1->sum>max)
{
max=p1->sum;
max1=p1;
}
p1=p1->next;
}
printf("%d %d\n",max1->num,max1->sum);
p1=head;
max=0;
while(p1!=NULL)
{
if(p1->sum>max&&p1!=max1)
{
max=p1->sum;
max2=p1;
}
p1=p1->next;
}
printf("%d %d\n",max2->num,max2->sum);
p1=head;
max=0;
while(p1!=NULL)
{
if(p1->sum>max&&p1!=max1&&p1!=max2)
{
max=p1->sum;
max3=p1;
}
p1=p1->next;
}
printf("%d %d\n",max3->num,max3->sum);
}
/*if(n<3)
{
int max=0; //???????????????????????????p=a?????????...
if(*/
| 14 |
6,970 | struct score
{
long num;
int yu;
int shu;
int sum;
}stu[100000];
void main()
{
long i,n,j,k;
int t;
scanf("%ld",&n);
for(i=0;i<n;i++)
{
scanf("%ld%d%d",&stu[i].num,&stu[i].yu,&stu[i].shu);
stu[i].sum=stu[i].yu+stu[i].shu;
}
for(i=0;i<3;i++)
{
for(j=0;j<n-i-1;j++)
if(stu[j].sum>stu[j+1].sum)
{
t=stu[j].sum;
stu[j].sum=stu[j+1].sum;
stu[j+1].sum=t;
}
}
for(k=n-1;k>n-4;k--)
{
if(k!=n-1&&stu[k].sum==stu[k+1].sum)continue;
for(i=0;i<n;i++)
{
if(stu[k].sum==(stu[i].yu+stu[i].shu))
{ printf("%ld %ld\n",stu[i].num,stu[k].sum);
if(k==n-3)break;}
}
}
}
| 14 |
6,971 | void main()
{ int m1,m2,m3,n1,n2,n3;
struct student{int num;int verbal;int math;int sum;};
struct student stu[100000];
struct student *p;
p=stu;
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&(p+i)->num,&(p+i)->verbal,&(p+i)->math);
for(i=0;i<n;i++)
(p+i)->sum=(p+i)->verbal+(p+i)->math;
m1=p->sum;n1=0;
for(i=0;i<n;i++)
if(((p+i)->sum)>m1)
{m1=(p+i)->sum;
n1=i;}
printf("%d %d\n",(p+n1)->num,(p+n1)->sum);
m2=p->sum;n2=0;
for(i=0;i<n;i++)
if(((p+i)->sum)>m2&&i!=n1)
{m2=(p+i)->sum;
n2=i;}
printf("%d %d\n",(p+n2)->num,(p+n2)->sum);
m3=p->sum;n3=0;
for(i=0;i<n;i++)
if((((p+i)->sum)>m3)&&i!=n1&&i!=n2)
{m3=(p+i)->sum;
n3=i;}
printf("%d %d\n",(p+n3)->num,(p+n3)->sum);
}
| 14 |
6,972 | struct student
{
int id;
int c;
int m;
int s;
struct student *next;
};
struct student *creat(void)
{
struct student *head,*p1,*p2;
int n,i;
p1=p2=(struct student*)malloc(LEN);
scanf("%d",&n);
head=NULL;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&p1->id,&p1->c,&p1->m);
p1->s=p1->c+p1->m;
if(i==0)head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
}
p2->next=NULL;
return (head);
}
void exchange(struct student *x,struct student *y)
{
int t;
t=x->id;x->id=y->id;y->id=t;
t=x->c;x->c=y->c;y->c=t;
t=x->m;x->m=y->m;y->m=t;
t=x->s;x->s=y->s;y->s=t;
}
void main()
{
struct student *p,*q,*head;
int temp,i;
head=p=creat();
for(p=head,i=0;p->next!=NULL,i<3;p=p->next,i++)
{
temp=p->s;
for(q=p->next;q!=NULL;q=q->next)
{
if(p->s<q->s)temp=q->s;
if(p->s!=temp)exchange(p,q);
}
}
for(p=head,i=0;i<3;p=p->next,i++)
printf("%d %d\n",p->id,p->s);
}
| 14 |
6,973 |
struct stu
{
int num;
int mark1;
int mark2;
long int total_mark;
};
int main(void)
{
int n,i,j,k,t=0,max;
struct stu *p;
struct stu *q;
scanf("%d",&n);
p=(struct stu *)malloc(1000000*sizeof(struct stu));
q=p;
for(i=0;i<n;i++)
{
scanf("%d %d %d",&(p+i)->num,&(p+i)->mark1,&(p+i)->mark2);
(p+i)->total_mark=(p+i)->mark1+(p+i)->mark2;
}
loop: max=0;
for(j=0;j<n;j++)
{
if((p+j)->total_mark>max)
max=(p+j)->total_mark;
}
for(k=0;k<n;k++)
if(max==(p+k)->total_mark&&k<n)
{
printf("%d %ld\n",(p+k)->num,(p+k)->total_mark);
t++;
(p+k)->total_mark=0;
break;
}
if(t<3) goto loop;
} | 14 |
6,974 | struct stu{
int ID;
int ch;
int ma;
int sum;
struct stu *next;
};
int main(){
struct stu *head;
struct stu *p1,*p2,*a,*b,*c,*t;
int n,i=0;
a=b=c=p1=p2=(struct stu *) malloc(sizeof(struct stu));
scanf("%d",&n);
scanf("%d%d%d",&p1->ID,&p1->ch,&p1->ma);
p1->sum=p1->ch+p1->ma;
head=NULL;
while(i<n-1){
i++;
p1->sum=p1->ch+p1->ma;
if(i==1)head=p1;
else p2->next=p1;
p2=p1;
if(p1->sum>a->sum) {c=b;b=a;a=p2;}
else if(p1->sum>b->sum) {c=b;b=p2;}
else if(p1->sum>c->sum) c=p2;
p1=(struct stu *) malloc(sizeof(struct stu));
scanf("%d%d%d",&p1->ID,&p1->ch,&p1->ma);
}
p2->next=NULL;
printf("%d %d\n%d %d\n%d %d\n",a->ID,a->sum,b->ID,b->sum,c->ID,c->sum);
return 0;
}
| 14 |
6,975 | struct stu
{int xuehao,yuwen,shuxue,sum;
struct stu *next;
};
void max(struct stu *h)
{
struct stu *a,*b,*c,*d;
int m=0;
a=h;
do
{
c=a;
a=a->next;
if(m<a->sum)
{
m=a->sum;
d=c;
b=a;
}
}while(a->next);
printf("%d %d\n",b->xuehao,b->sum);
d->next=b->next;
free(b);
}
void main()
{
struct stu *head,*p,*q;
int n,i;
scanf("%d",&n);
head=M;
p=M;
head->next=p;
for(i=0;i<n;i++){
scanf("%d %d %d",&p->xuehao,&p->yuwen,&p->shuxue);
p->sum=p->yuwen+p->shuxue;
q=M;
p->next=q;
p=q;
}
p->next=NULL;
max(head);
max(head);
max(head);
}
| 14 |
6,976 | int main(int argc, char* argv[])
{
struct grades{
int id;
int yuwen,shuxue;
int zongfen ;
}grades[100007];
int i,n,j,t,s;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&grades[i].id,&grades[i].yuwen,&grades[i].shuxue);
grades[i].zongfen=grades[i].yuwen+grades[i].shuxue;
}
for(i=0;i<3;i++)
{
for(j=0;j<n-1;j++)
{
if(grades[j].zongfen>=grades[j+1].zongfen)
{
t=grades[j].zongfen;
grades[j].zongfen=grades[j+1].zongfen;
grades[j+1].zongfen=t;
s=grades[j].id;
grades[j].id=grades[j+1].id;
grades[j+1].id=s;
}
}
}
for(i=n-1;i>=n-3;i--)
{
printf("%d %d\n",grades[i].id,grades[i].zongfen);
}
return 0;
} | 14 |
6,977 | struct student
{
int num;
int sum;
}stu[100000];
int main()
{
int n,i,j,t,a,b,m;
int tempSum;
int tempMax;
int rank[3]={0};
scanf("%d",&n);
//struct student * stu;
//stu = (struct student *)malloc(sizeof(struct student) * n);
for(i=0;i<n;i++)
{
tempSum = 0;
scanf("%d",&stu[i].num);
stu[i].sum = 0;
for(j=0;j<2;j++){
scanf("%d",&tempSum);
stu[i].sum += tempSum;
}
}
for(b=0;b<3;b++)
{
tempMax = 0;
for(a=b;a<n;a++)
{
if(stu[a].sum > tempMax){
tempMax = stu[a].sum;
rank[b] = a;
}
}
t = stu[b].num;
stu[b].num = stu[rank[b]].num;
stu[rank[b]].num = t;
t = stu[b].sum;
stu[b].sum = stu[rank[b]].sum;
stu[rank[b]].sum = t;
}
for(a=0;a<3;a++)
printf("%d %d\n",stu[a].num,stu[a].sum);
return 0;
}
| 14 |
6,978 | struct stu
{
int num;
int score1;
int score2;
}
main()
{
struct stu damn[4];
int n,i,j,total;
scanf("%d",&n);
for(i=0;i<3;i++) scanf("%d %d %d",&damn[i].num,&damn[i].score1,&damn[i].score2);
for(i=0;i<2;i++)
{
for(j=0;j<2-i;j++)
{
if(damn[j].score1+damn[j].score2<damn[j+1].score1+damn[j+1].score2)
{
damn[3]=damn[j];
damn[j]=damn[j+1];
damn[j+1]=damn[3];
}
}
}
for(i=0;i<n-3;i++)
{
scanf("%d %d %d",&damn[3].num,&damn[3].score1,&damn[3].score2);
if(damn[3].score1+damn[3].score2<damn[2].score1+damn[2].score2) continue;
else if(damn[3].score1+damn[3].score2<=damn[1].score1+damn[1].score2&&damn[3].score1+damn[3].score2>damn[2].score1+damn[2].score2)
{
damn[2]=damn[3];
}
else if(damn[3].score1+damn[3].score2<=damn[0].score1+damn[0].score2&&damn[3].score1+damn[3].score2>damn[1].score1+damn[1].score2)
{
damn[2]=damn[1];
damn[1]=damn[3];
}
else if(damn[3].score1+damn[3].score2>damn[0].score1+damn[0].score2)
{
damn[2]=damn[1];
damn[1]=damn[0];
damn[0]=damn[3];
}
}
for(i=0;i<2;i++)
{
total=damn[i].score1+damn[i].score2;
printf("%d %d\n",damn[i].num,total);
}
total=damn[i].score1+damn[i].score2;
printf("%d %d",damn[i].num,total);
}
| 14 |
6,979 | int s[100001];
int main()
{
int n,i,j;
scanf("%d",&n);
struct{
int id,chin,math,su;
}s[100001];
for(i=0;i<n;i++)
{
scanf("%d%d%d",&s[i].id,&s[i].chin,&s[i].math);
s[i].su=s[i].chin+s[i].math;
}
for(i=0;i<3;i++)
{
for(j=i+1;j<n;j++)
{
if(s[i].su<s[j].su)
{
s[100000]=s[i];
s[i]=s[j];
s[j]=s[100000];
}
}
}
printf("%d %d\n%d %d\n%d %d",s[0].id,s[0].su,s[1].id,s[1].su,s[2].id,s[2].su);
return 0;
} | 14 |
6,980 | struct student
{
int no;
int yuwen;
int shuxue;
int total;
};
void main()
{
int n,i;
struct student *p,*stu,temp;
scanf("%d",&n);
stu=(struct student *)calloc(n,sizeof(struct student));
for(p=stu;p-stu<n;p++)
{
scanf("%d%d%d",&p->no,&p->yuwen,&p->shuxue);
p->total=p->yuwen+p->shuxue;
}
for(i=0;i<3;i++)
{
for(p=stu+n-1;p>stu+i;p--)
{
if(p->total>(p-1)->total)
{
temp=*p;
*p=*(p-1);
*(p-1)=temp;
}
}
printf("%d %d\n",p->no,p->total);
}
free(stu);
} | 14 |
6,981 | struct stu
{
int num;
int yw;
int sx;
int zf;
}s1,s2,s3,s;
int main()
{
int n,i;
s1.zf=s2.zf=s3.zf=-1;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&s.num,&s.yw,&s.sx);
s.zf=s.yw+s.sx;
if(s.zf>s1.zf)
{
s3=s2;
s2=s1;
s1=s;
}
else if(s.zf>s2.zf)
{
s3=s2;
s2=s;
}
else if(s.zf>s3.zf)
{
s3=s;
}
}
printf("%d %d\n",s1.num,s1.zf);
printf("%d %d\n",s2.num,s2.zf);
printf("%d %d",s3.num,s3.zf);
return 0;
} | 14 |
6,982 | int main()
{
int i,j,n;
struct point
{
int m,x,y;
}a[100000],aa;
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%d%d%d",&a[i].m,&a[i].x,&a[i].y);
}
for(i=0;i<3;i++)
{
for (j=i+1;j<n;j++)
{
if ((a[i].x+a[i].y)<(a[j].x+a[j].y))
{
aa=a[j];
a[j]=a[i];
a[i]=aa;
}
}
}
for (i=0;i<3;i++)
{
printf ("%d %d\n",a[i].m,(a[i].x+a[i].y));
}
return 0;
} | 14 |
6,983 | int a[100000][3],s[100000],x=0,y=0,z=0,x1=0,y1=0,z1=0;
int main()
{
int n,i,j;
scanf("%d",&n);
for (i=1;i<=n;i++)
{
for (j=0;j<3;j++)
{scanf("%d",&a[i][j]);}
s[i]=a[i][1]+a[i][2];
}
for (i=1;i<=n;i++)
{
if (s[i]>x)
{ x=s[i];
x1=a[i][0];}
}
for (i=1;i<=n;i++)
{
if(s[i]>y&&i!=x1)
{ y=s[i];
y1=a[i][0];}
}
for (i=1;i<=n;i++)
{
if(s[i]>z&&i!=x1&&i!=y1)
{z=s[i];
z1=a[i][0]; }
}
printf("%d %d\n",x1,x);
printf("%d %d\n",y1,y);
printf("%d %d\n",z1,z);
return 0;
}
| 14 |
6,984 | int stu [100000];
int main(int argc, char* argv[])
{
int n,i,j,y,t,m;
struct s{
int a;
int b;
int c;
}stu[100000];
scanf ("%d",&n);
for (i=0;i<n;i++)
{
scanf ("%d%d%d",&stu[i].a,&stu[i].b,&stu[i].c);
}
for (i=0;i<3;i++)
{
for (j=i+1;j<n;j++)
{
if ((stu[j].b+stu[j].c)>(stu[i].b+stu[i].c))
{
y=stu[i].b;t=stu[i].c;m=stu[i].a;
stu[i].b=stu[j].b;
stu[j].b=y;
stu[i].c=stu[j].c;
stu[j].c=t;
stu[i].a=stu[j].a;
stu[j].a=m;
}
}
}
for (i=0;i<3;i++)
{
printf ("%d %d\n",stu[i].a,(stu[i].b+stu[i].c));
}
return 0;
}
| 14 |
6,985 | int pfCompare(const void* elem1,const void* elem2)
{
int d;
d=*((int*)elem2)-*((int*)elem1);
return d;
}
struct student
{
long int ID;
long int c;
long int m;
};
int main()
{
long int n,i,j,k;
int b[100000];
int e[3];
scanf("%d",&n);
struct student a[100000];
for(i=0;i<n;i++)
{
scanf("%d %d %d",&a[i].ID,&a[i].c,&a[i].m);
}
for(i=0;i<n;i++)
{
b[i]=a[i].c+a[i].m;
}
qsort(b,n,sizeof(long int),pfCompare);
for(i=0;i<n;i++)
{
if(b[0]==a[i].c+a[i].m)
{
e[0]=a[i].ID;
j=i;
break;
}
}
for(i=0;i<n;i++)
{
if((b[1]==a[i].c+a[i].m)&&i!=j)
{
e[1]=a[i].ID;
k=i;
break;
}
}
for(i=0;i<n;i++)
{
if((b[2]==a[i].c+a[i].m)&&i!=j&&i!=k)
{
e[2]=a[i].ID;
break;
}
}
for(i=0;i<=2;i++)
{
printf("%d %d\n",e[i],b[i]);
}
getchar();
getchar();
getchar();
} | 14 |
6,986 |
int main()
{
int n,i,j,k,z,x;
scanf("%d",&n);
struct Student
{
int num;
int yuwen;
int shuxue;
int zongfen;
}stu[n];
for(i=0;i<n;i++)
{
scanf("%d%d%d",&stu[i].num,&stu[i].yuwen,&stu[i].shuxue);
stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;
}
for(j=0;j<3;j++)
{
for(k=0;k<n-1;k++)
{
if(stu[k].zongfen>stu[k+1].zongfen)
{
z=stu[k+1].zongfen;
stu[k+1].zongfen=stu[k].zongfen;
stu[k].zongfen=z;
x=stu[k+1].num;
stu[k+1].num=stu[k].num;
stu[k].num=x;
}
else if(stu[k].zongfen==stu[k+1].zongfen&&stu[k].num<stu[k+1].num)
{
z=stu[k+1].zongfen;
stu[k+1].zongfen=stu[k].zongfen;
stu[k].zongfen=z;
x=stu[k+1].num;
stu[k+1].num=stu[k].num;
stu[k].num=x;
}
else;
}
}
for(j=0;j<3;j++)
{
printf("%d %d\n",stu[n-1-j].num,stu[n-1-j].zongfen);
}
getchar();
getchar();
}
| 14 |
6,987 | struct student
{
int num;
int score1;//????
int score2;//????
int total;
};
struct student stu[100000];
int main()
{
long i,m;
scanf("%ld",&m);
struct student *p=stu;
for(i=0;i<m;i++,p++)
{
scanf("%d%d%d",&(p->num),&(p->score1),&(p->score2));
p->total=(p->score1+p->score2);
}
int max1,max2,max3,a1=0,a2=0,a3=0;
max1=stu[0].total;
for(i=0;i<m;i++)
{
if(stu[i].total>max1) {max1=stu[i].total;a1=i;}
}
max2=stu[0].total;
for(i=0;i<m;i++)
{
if(stu[i].total>max2&&i!=a1) {max2=stu[i].total;a2=i;}
}
max3=stu[0].total;
for(i=0;i<m;i++)
{
if(stu[i].total>max3&&stu[i].total<max2) {max3=stu[i].total;a3=i;}
}
printf("%d %d\n",stu[a1].num,stu[a1].total);
printf("%d %d\n",stu[a2].num,stu[a2].total);
printf("%d %d",stu[a3].num,stu[a3].total);
return 0;
} | 14 |
6,988 | int main()
{
struct student
{
int num;
int chinese;
int math;
int sum;
}m[4],t;
int n,i;
scanf("%d",&n);
for(i=1;i<=3;i++)
m[i].sum=-1;
for(i=1;i<=n;i++)
{
scanf("%d %d %d",&t.num,&t.chinese,&t.math);
t.sum=t.chinese+t.math;
if(t.sum>m[1].sum)
{
m[3]=m[2];
m[2]=m[1];
m[1]=t;
}
else
if(t.sum>m[2].sum)
{
m[3]=m[2];
m[2]=t;
}
else
if(t.sum>m[3].sum)
m[3]=t;
}
for(i=1;i<=3;i++)
printf("%d %d\n",m[i].num,m[i].sum);
} | 14 |
6,989 | void main()
{
struct stu
{int a,b,c;};
int i,n,j=0;scanf("%d",&n);
struct stu *hd,*p;
hd=p=(struct stu*)malloc(100000*sizeof(struct stu));
for(i=0;i<n;i++,p++)
{scanf("%d %d %d",&p->a,&p->b,&p->c);}
int max=0;
nxt: for(p=hd,i=0;i<n;i++,p++)
{
if(p->b+p->c>max) {max=p->b+p->c;}
}
for(p=hd,i=0;i<n;i++,p++)
{
if(p->b+p->c==max) {printf("%d %d\n",p->a,p->b+p->c);p->b=0;p->c=0;max=0;j++;break;}
}
if(j<=2) goto nxt;
} | 14 |
6,990 | struct student
{char num[10];
int chinese;
int math;
int sum;
struct student *next;
};
int n;
struct student *creat(int n)
{
struct student *head,*p1,*p2;
p1=p2=(struct student *)malloc(LEN);
scanf("%s %d %d",p1->num,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
head=NULL;
int t=n;
while(n>1)
{
if(n==t) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%s %d %d",p1->num,&p1->chinese,&p1->math);
p1->sum=p1->chinese+p1->math;
n--;
}
p2->next=NULL;
return(head);
}
void main()
{
int n,i;struct student *first,*second,*third;
int fir_index,sec_index,thr_index;
scanf("%d",&n);struct student *head,*p1;struct student stu;
head=creat(n);
first=head;second=head;third=head;
for(p1=head;p1->next!=NULL;p1=p1->next)
{
if(p1->sum>first->sum)
{
third=second;second=first;first=p1;
}
else if(p1->sum>second->sum)
{
third=second;second=p1;
}
else if(p1->sum>third->sum)
{
third=p1;
}
}
printf("%s %d\n",first->num,first->sum);
printf("%s %d\n",second->num,second->sum);
printf("%s %d\n",third->num,third->sum);
}
| 14 |
6,991 |
int main()
{
int a[3], n,c,b,d,g[3], i,temp;
int j = 0;
scanf("%d",&n);
for(i = 0; i < 3; i++)
{
scanf("%d %d %d", &d,&b,&c);
g[i] = d;
a[i] = b+c;
}
for (i = 0; i < 3 - 1; i++)
for (j = 0; j < 3 - 1 - i; j++)
if (a[j] < a[j+1]) {
temp = a[j] ;
a[j] = a[j+1];
a[j+1] = temp;
temp = g[j];
g[j] = g[j+1];
g[j+1] = temp;
}
for(i=3;i<n;i++)
{
scanf("%d %d %d",&d,&b,&c);
temp=b+c;
if(temp <= a[2])
{
continue;
} else {
if (a[1] >= temp){
a[2] = temp;
g[2]=d;
}
else {
a[2] = a[1];
g[2]=g[1];
if(a[0] >=temp){
a[1]=temp;
g[1]=d;
}
else {
a[1]=a[0];
g[1]=g[0];
a[0]=temp;
g[0]=d;
}
}
}
}
printf("%d %d\n%d %d\n%d %d\n",g[0],a[0],g[1],a[1],g[2],a[2]);
} | 14 |
6,992 | struct stu
{
int ID;
int Chinese;
int math;
int sum;
}zz[100000],mx,mx1,mx2;
int main()
{
int n,i,j;
cin>>n;
for ( i = 0 ; i < n ; i ++ )
{
cin>>zz[i].ID>>zz[i].Chinese>>zz[i].math;
zz[i].sum = zz[i].Chinese + zz[i].math;
}
mx = zz[0];
for ( i = 0 ; i < n ; i ++ )
{
if ( zz[i].sum > mx.sum )
mx = zz[i];
}
cout<<mx.ID<<' '<<mx.sum<<endl;
mx.sum=0;
mx1 = mx;
for ( i = 0 ; i < n ; i ++ )
{
if ( zz[i].sum > mx1.sum )
{
if ( zz[i].ID == mx.ID )
continue;
mx1 = zz[i];
}
}
cout<<mx1.ID<<' '<<mx1.sum<<endl;
mx1.sum=0;
mx2 = mx1;
for ( i = 0 ; i < n ; i ++ )
{
if ( zz[i].sum > mx2.sum )
{
if ( zz[i].ID == mx.ID || zz[i].ID == mx1.ID)
continue;
mx2 = zz[i];
}
}
cout<<mx2.ID<<' '<<mx2.sum<<endl;
} | 14 |
6,993 | /*
* jiegou_1.cpp
*
* Created on: 2011-1-2
* Author: Iris
* ????????
* ????STUDENT_NUM???????????????? ?????????ID???????????
* ???????????????????????????????
*/
int main(){
int n,i;
cin>>n;//??????
struct student{
int stuNo;
int yuwen;
int shuxue;
int zongfen;
} stu[n];//?????????????????????????t?????
struct tri{
int stuNo;
int zongfen;
} qian[3]={0,0,0,0,0,0};//??????????????????????
for(i=0;i<n;i++){
cin>>stu[i].stuNo;
cin>>stu[i].yuwen;
cin>>stu[i].shuxue;//????????????
stu[i].zongfen=stu[i].yuwen+stu[i].shuxue;//?????????
}
for(i=0;i<n;i++){
if(stu[i].zongfen>qian[0].zongfen){
qian[2]=qian[1];
qian[1]=qian[0];
qian[0].stuNo=stu[i].stuNo;
qian[0].zongfen=stu[i].zongfen;
continue;
}
if(stu[i].zongfen>qian[1].zongfen){
qian[2]=qian[1];
qian[1].stuNo=stu[i].stuNo;
qian[1].zongfen=stu[i].zongfen;
continue;
}
if(stu[i].zongfen>qian[2].zongfen){
qian[2].stuNo=stu[i].stuNo;
qian[2].zongfen=stu[i].zongfen;
}
}//?????
for(i=0;i<3;i++)
cout<<qian[i].stuNo<<' '<<qian[i].zongfen<<endl;//????????????
return 0;
}
| 14 |
6,994 | void main()
{
int i,j,k,m,n,max;
struct stu
{
int xh;
int yw;
int sx;
int zf;
struct stu *next;
};
struct stu *p1,*p2,*head;
scanf("%d",&n);
p2=head=p1=(struct stu *)malloc(sizeof(struct stu));
scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
p1->zf=p1->yw+p1->sx;
for(i=1;i<n;i++)
{
p1=(struct stu *)malloc(sizeof(struct stu));
scanf("%d %d %d",&p1->xh,&p1->yw,&p1->sx);
p1->zf=p1->yw+p1->sx;
p2->next=p1;
p2=p1;
}
for(j=0;j<3;j++)
{
p1=head;
max=0;
for(i=0;i<n;i++)
{
max=max>p1->zf?max:p1->zf;
p1=p1->next;
}
p1=head;
for(i=0;i<n;i++)
{
if(max==p1->zf)
{
printf("%d %d\n",p1->xh,p1->zf);
p1->zf=0;
break;
}
p1=p1->next;
}
}
} | 14 |
6,995 |
int main()
{
struct st
{int id;
int yu;
int ma;
};
int n,i;
struct st st1={0,0,0},st2={0,0,0},st3={0,0,0},stn;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&stn.id,&stn.yu,&stn.ma);
if(stn.yu+stn.ma>st1.yu+st1.ma){
st3=st2;
st2=st1;
st1=stn;
}else{
if(stn.yu+stn.ma>st2.yu+st2.ma){
st3=st2;
st2=stn;
}else{
if(stn.yu+stn.ma>st3.yu+st3.ma){
st3=stn;
}
}
}
}
printf("%d %d\n%d %d\n%d %d",st1.id,st1.yu+st1.ma,st2.id,st2.yu+st2.ma,st3.id,st3.yu+st3.ma);
} | 14 |
6,996 | int main()
{
int n;
scanf ("%d",&n);
struct student
{
int num;
int chinese;
int maths;
};
struct student a[100000],temp;
int i,b[100000]={0};
for (i=0;i<n;i++)
{
scanf("%d",&a[i].num);
scanf("%d",&a[i].chinese);
scanf("%d",&a[i].maths);
}
for (i=1;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[0].chinese+a[0].maths))
{
temp=a[0];
a[0]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[0].num,a[0].chinese+a[0].maths);
for (i=2;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[1].chinese+a[1].maths))
{
temp=a[1];
a[1]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[1].num,a[1].chinese+a[1].maths);
for (i=3;i<n;i++)
{
if ((a[i].chinese+a[i].maths)>(a[2].chinese+a[2].maths))
{
temp=a[2];
a[2]=a[i];
a[i]=temp;
}
}
printf("%d %d\n",a[2].num,a[2].chinese+a[2].maths);
return 0;
} | 14 |
6,997 |
int main(int argc, char* argv[])
{
long n;
long num[99999],math[99999],china[99999],z[99999],i;
long num1=2,num2=1,num3=0,m1=0,m2=0,m3=0;
scanf("%ld",&n);
for(i=1;i<=n;i++)
{
scanf("%ld",&num[i]);
scanf("%ld",&math[i]);
scanf("%ld",&china[i]);
z[i]=math[i]+china[i];
if(z[i]>num3)
{
num1=num2;
m1=m2;
num2=num3;
m2=m3;
num3=z[i];
m3=i;
}
else if(z[i]>num2)
{
num1=num2;
m1=m2;
num2=z[i];
m2=i;
}
else if(z[i]>num1)
{
num1=z[i];
m1=i;
}
}
printf("%ld %ld\n",m3,num3);
printf("%ld %ld\n",m2,num2);
printf("%ld %ld\n",m1,num1);
return 0;
} | 14 |
6,998 | struct student
{int id;
int chinese;
int maths;
int total;
};
void main()
{
int n,i;
struct student s,s1,s2,s3;
scanf("%d",&n);
s2.total=s1.total=s3.total=-1;
for(i=0;i<n;i++)
{ scanf("%d %d %d",&s.id,&s.chinese,&s.maths);
s.total=s.chinese+s.maths;
if(s.total>s1.total)
{ s3=s2;
s2=s1;
s1=s;
}
else if(s.total>s2.total)
{ s3=s2;
s2=s;
}
else if(s.total>s3.total)
s3=s;
}
printf("%d %d\n",s1.id,s1.total);
printf("%d %d\n",s2.id,s2.total);
printf("%d %d\n",s3.id,s3.total);
} | 14 |
6,999 | int main()
{
struct student
{
int ID;
int yuwen;
int shuxue;
};
int n,i,x,y,z,o,p,q;
scanf("%d",&n);
int a[100000];
struct student stu[100000];
for(i=0;i<n;i++)
{
scanf("%d %d %d",&stu[i].ID,&stu[i].yuwen,&stu[i].shuxue);
a[i]=stu[i].yuwen+stu[i].shuxue;
}
x=0;
y=1;
z=2;
for(i=0;i<3;i++)
{
if(a[i]>=a[0]&&a[i]>=a[1]&&a[i]>=a[2])
{
x=i;
o=a[i];
continue;
}
if(a[i]<=a[0]&&a[i]<=a[1]&&a[i]<=a[2])
{
z=i;
q=a[i];
continue;
}
y=i;
p=a[i];
}
for(i=3;i<n;i++)
{
if(a[i]>q)
{
if(a[i]>o)
{
z=y;
y=x;
x=i;
q=p;
p=o;
o=a[i];
}
else
{
if(a[i]>p)
{
z=y;
y=i;
q=p;
p=a[i];
}
else
{
z=i;
q=a[i];
}
}
}
}
printf("%d %d\n",stu[x].ID,o);
printf("%d %d\n",stu[y].ID,p);
printf("%d %d\n",stu[z].ID,q);
getchar();
getchar();
}
| 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.