Click Here to go back to the homepage.

Server Solution:


import java.util.Scanner;

public class Kattis {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] firstLn = sc.nextLine().split(" ");
    int jobs = Integer.parseInt(firstLn[0]);
    int lim = Integer.parseInt(firstLn[1]);
    String[] data = sc.nextLine().split(" ");
    int count = 0;
    int sum = 0;
    for (int i = 0; i < data.length; i++) {
      if(sum + Integer.parseInt(data[i]) <= lim) {
        sum += Integer.parseInt(data[i]);
        count++;
      }
      else break;
    }
    System.out.println(count);
  }
}