#9 错误,求调

P1051 [NOIP2005 提高组] 谁拿了最多奖学金

改了一下排序,AC了,此帖完 ```cpp #include<bits/stdc++.h> using namespace std; struct node{ string name; int qmcj,pycj; char gb,xb; int lw,jxj=0; }a[100001]; bool ys(node x){ if(x.qmcj>80&&x.lw>0) return 1; return 0; } bool ws(node x){ if(x.qmcj>85&&x.pycj>80) return 1; return 0; } bool cj(node x){ if(x.qmcj>90) return 1; return 0; } bool xb(node x){ if(x.qmcj>85&&x.xb=='Y') return 1; return 0; } bool gx(node x){ if(x.pycj>80&&x.gb=='Y') return 1; return 0; } bool cmp(node q,node h){ return q.jxj<h.jxj; } int main(){ int n,sum=0; cin>>n; for(int i=1;i<=n;i++) cin>>a[i].name>>a[i].qmcj>>a[i].pycj>>a[i].gb>>a[i].xb>>a[i].lw; for(int i=1;i<=n;i++){ if(ys(a[i])) a[i].jxj+=8000; if(ws(a[i])) a[i].jxj+=4000; if(cj(a[i])) a[i].jxj+=2000; if(xb(a[i])) a[i].jxj+=1000; if(gx(a[i])) a[i].jxj+=850; } sort(a+1,a+1+n,cmp); for(int i=1;i<=n;i++) sum+=a[i].jxj; cout<<a[n].name<<endl<<a[n].jxj<<endl; cout<<sum; return 0; } ```
by Alpex @ 2022-09-15 21:19:17


|