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 |
Why WA? I am really confused(With code)#include <iostream> #include <cstdlib> #include <iomanip> using namespace std; int main() { int xp, n, quest[10][4], i, j, k, order[10], maxcurr; float poss, maxcurrposs, cur; cin>>n>>xp; for(i=0;i<n;i++){ cin>>quest[i][0]>>quest[i][1]>>quest[i][2]; quest[i][3]=0; } memset(order,0,sizeof(order)); k=0; poss=1.0; for(i=0;i<n;i++){ maxcurrposs=0; for(j=0;j<n;j++){ if(quest[j][3]) continue; if(xp<quest[j][0]){ cur=0.0; }else if(xp>quest[j][1]){ cur=1.0; }else{ cur=((float)xp-(float)quest[j][0])/((float)quest[j][1]-(float)quest[j][0]); } if(cur>maxcurrposs){ maxcurrposs = cur; maxcurr = j; } } if(maxcurrposs==0){ for(j=0;j<n;j++){ if(quest[j][3]) continue; order[k++]=j+1; } poss=0.0; break; }else{ poss*=maxcurrposs; order[k++]=maxcurr+1; quest[maxcurr][3]=1; } xp+=quest[maxcurr][2]; } cout<<fixed<<setprecision(3)<<poss<<endl; for(i=0;i<n;i++){ cout<<order[i]<<" "; } cout<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator