#7#8错了,求助

P1093 [NOIP2007 普及组] 奖学金

Maxzero @ 2019-05-03 13:23:46

include <iostream>

using namespace std; int main() { int n,i=1,x[301],y[301],a,b,c,t1=0,t2=0,t3=0,t5=0,t4=0,l1=0,l2=0,l3=0,l4=0,l5=0; cin>>n; while(i<=n) { cin>>a>>b>>c; x[i]=a+b+c; y[i]=a; i++; } i=1; while(i<=n) { if(x[i]>t1)t1=x[i],l1=i; else if(x[i]==t1&&y[i]>y[l1])l1=i; i++; } i=1; while(i<=n) { if(x[i]>t2&&i!=l1)t2=x[i],l2=i; else if(x[i]==t2&&y[i]>y[l2]&&i!=l1)l2=i; i++; } i=1; while(i<=n) { if(x[i]>t3&&i!=l1&&i!=l2)t3=x[i],l3=i; else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2)l3=i; i++; } i=1; while(i<=n) { if(x[i]>t4&&i!=l1&&i!=l2&&i!=l3)t4=x[i],l4=i; else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3)l4=i; i++; } i=1; while(i<=n) { if(x[i]>t5&&i!=l1&&i!=l2&&i!=l3&&i!=l4)t5=x[i],l5=i; else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3&&i!=l4)l5=i; i++; } if(n>=1)cout<<l1<<" "<<t1<<endl; if(n>=2)cout<<l2<<" "<<t2<<endl; if(n>=3)cout<<l3<<" "<<t3<<endl; if(n>=4)cout<<l4<<" "<<t4<<endl; if(n>=5)cout<<l5<<" "<<t5<<endl; }


by 潜翎 @ 2019-05-03 13:31:31

这么硬核谁敢看啊


by DepletedPrism @ 2019-05-03 13:40:02

希望更丰富的展现?使用Markdown


by Smile_Cindy @ 2019-05-03 13:51:54

希望更丰富的展现?使用Markdown


by Maxzero @ 2019-05-03 15:08:20

include <iostream>

using namespace std; int main() {

int n,i=1,x[301],y[301],a,b,c,t1=0,t2=0,t3=0,t5=0,t4=0,l1=0,l2=0,l3=0,l4=0,l5=0;

cin>>n;
while(i<=n)
{
    cin>>a>>b>>c;
    x[i]=a+b+c;
    y[i]=a;
    i++;
}
i=1;
while(i<=n)
{
    if(x[i]>t1)t1=x[i],l1=i;
    else if(x[i]==t1&&y[i]>y[l1])l1=i;
    i++;
}
i=1;
while(i<=n)
{
    if(x[i]>t2&&i!=l1)t2=x[i],l2=i;
    else if(x[i]==t2&&y[i]>y[l2]&&i!=l1)l2=i;
    i++;
}
i=1;
    while(i<=n)
{
    if(x[i]>t3&&i!=l1&&i!=l2)t3=x[i],l3=i;
    else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2)l3=i;
    i++;
}
i=1;
    while(i<=n)
{
    if(x[i]>t4&&i!=l1&&i!=l2&&i!=l3)t4=x[i],l4=i;
    else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3)l4=i;
    i++;
}
i=1;
    while(i<=n)
{
    if(x[i]>t5&&i!=l1&&i!=l2&&i!=l3&&i!=l4)t5=x[i],l5=i;
    else if(x[i]==t2&&y[i]>y[l2]&&i!=l1&&i!=l2&&i!=l3&&i!=l4)l5=i;
    i++;
}

if(n>=1)cout<<l1<<" "<<t1<<endl; if(n>=2)cout<<l2<<" "<<t2<<endl; if(n>=3)cout<<l3<<" "<<t3<<endl; if(n>=4)cout<<l4<<" "<<t4<<endl; if(n>=5)cout<<l5<<" "<<t5<<endl; }


|