Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Why WA? I am really confused(With code)

Posted by Skies at 2009-06-25 21:00:09 on Problem 3413
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator