Tuesday, July 19, 2016

uva 11900 solution

Unknown
#include<cstdio>
using namespace std;

int main()
{
    int tc,c=1;
    scanf("%d",&tc);
    while (tc--)
    {
        int n,p,q,w[30],i,s=0;
        scanf("%d%d%d",&n,&p,&q);
        for (i=0;i<n;i++) scanf("%d",&w[i]);
        for (i=0;i<n && i<p;i++)
        {
            s+=w[i];
            if (s>q) break;
        }
        printf("Case %d: %d\n",c++,i);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,