Untitled
unknown
plain_text
2 years ago
585 B
12
Indexable
#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;
}
Editor is loading...