Pages

Friday, April 29, 2011

Monday, April 11, 2011

UVA Problem#11900

Question:

Solution:

1. take all the necessary inputs.
2. let count be the variable of the counter. you have to check so that count<P and count<N,then add the weight and recheck. Pseudo code is given below:
 
#include<stdio.h>

int main(){
    while(T--){
.......
.......
            for(W=count=0; count<P && count<N;){
                       if(W+a[count]>Q)
                       break;
                       W+=a[count++];
                       }

        printf("Case %d: %d\n", c++, count);

    }
    return 0;
}

Wednesday, April 6, 2011