2
I tried to solve the problem BANCO12 - Bank SPOJ, but when submitting my C++ code, the system returns "wrong answer". Follow my code: `
#include <iostream>
using namespace std;
int main(){
    int nc, np, i, c, livre=0, cont=0;
    cin>>nc>>np;
    int caixa[nc], espera[np], chegada, demora;
    for(i=0; i<nc; i++){
        caixa[i]=0;
    }
    for(i=0; i<np; i++){
        cin>>chegada>>demora;
        espera[i] = caixa[livre]-chegada;
        if(espera[i]>20){cont++;}
        caixa[livre]+=demora;
        if(nc>1){
            for(c=0; c<nc; c++){
                if(caixa[livre]>caixa[c]){
                    livre = c;
                }
            }
        }
    }
    cout<<cont<<endl;
    return 0;
}
I don’t know where the mistake is, can you help me?
remove the line
cout<<espera[i]<<endl;, your code has several exits and the site requires only the result.– Brumazzi DB
Sorry, I used this to make a test but forgot to withdraw, even without this line giving error. Still thank you!
– Felipe Regino
can be answer line break, try to use only
cout << cont;– Brumazzi DB
No, it was missing a test case, when the arrival is bigger than the free cash, I managed to solve. Thanks for the help!
– Felipe Regino