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