Untitled
unknown
plain_text
2 years ago
593 B
9
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],sum=0;
for (int j = 0; j < n; j++)
{
scanf("%d",&a[j]);
sum=sum+a[j];
}
if (sum<=h)
{
printf("0\n");
}
else
{
int j=0;
while (h-a[j]>0 && j<n)
{
h=h-a[j];
j++;
}
printf("%d\n",h);
}
}
return 0;
}
Editor is loading...