Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
585 B
1
Indexable
Never
#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for (int i= 1; i <=t; i++)
    {
        int n,h;
        scanf("%d %d",&n,&h);
        int a[n];
        
        for (int j = 0; j < n; j++)
        {
            scanf("%d",&a[j]);
        }
        int j=0;
        while (h>0 && j<n)
        {
            h=h-a[j];
            
            j++;
        }
        if (h>0)
        {
            printf("0\n");
        }
        else
        {
            printf("%d\n",h);
        }
        
        
    }
    
    return 0;
}