Solution please getting memory limit>256 ,time limit 1sec/file

Question:-
image

My answere:

   for (int i = 0; i < n;) {
			if (a[i] == 0) {
				break;
			}

			else {
				a[i] -= 1;
				cnt += 1;
			}
			if (i % n == 1) {
				i = 0;
			} else {
				i++;
			}
		}
Comments (0)