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 |
为什么我这样推不对呢?#include<stdio.h> #include<algorithm> using namespace std; struct pri { __int64 num; __int64 price; }; int main() { __int64 t,c,i,j; pri a[110]; scanf("%lld",&t); while(t--) { scanf("%lld",&c); for(i=0;i<c;i++) scanf("%lld %lld",&a[i].num,&a[i].price); if(c==1) { printf("%lld\n",(a[0].num+10)*a[0].price); continue; } for(i=1;i<c;i++) for(j=0;j<i;j++) if(a[j].num!=0) if((a[j].num+10)*a[j].price>=a[j].num*a[i].price) { a[i].num+=a[j].num; a[j].num=0; } __int64 sum=0; for(i=0;i<c;i++) if(a[i].num!=0) sum+=(a[i].num+10)*a[i].price; printf("%lld\n",sum); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator