uva 11900 solution

#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;
}

Comments

Popular posts from this blog

Codeforces 698A - Vacations

UVA 11364: Parking -Solution

UVA 11503 - Virtual Friends Solution