Skip to content

Instantly share code, notes, and snippets.

@Trimad
Created December 9, 2017 21:07
Show Gist options
  • Save Trimad/2a981d9c43d388ea079d8288d2da0a93 to your computer and use it in GitHub Desktop.
Save Trimad/2a981d9c43d388ea079d8288d2da0a93 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class KattisC {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String[] nT = new String[2];
nT = sc.nextLine().split(" ");
int n = Integer.parseInt(nT[0]);
int T = Integer.parseInt(nT[1]);
int counter = 0;
int sum = 0;
String[] posInts = new String[30];
posInts = sc.nextLine().split(" ");
while (counter < n) {
sum += Integer.parseInt(posInts[counter]);
if (sum > T) {
break;
}
counter++;
}
System.out.println(counter);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment