Created
December 9, 2017 21:07
-
-
Save Trimad/2a981d9c43d388ea079d8288d2da0a93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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