Submission #3199597


Source Code Expand

Copy
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ!!

        Scanner sc = new Scanner(System.in);
      int n=sc.nextInt();
      int m=sc.nextInt();
      int []num=new int[n];
      for(int i=0;i<n;i++){
      	num[i]=sc.nextInt();
      }
      Arrays.sort(num);
      int ans=0;
      for(int i=0;i<n;i++){
      	if(num[i]<=m){
        ans++;
          m-=num[i];
        }
        else{break}
      }
        System.out.println(ans);
    }
}

Submission Info

Submission Time
Task A - Candy Distribution Again
User Sigma1023
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 586 Byte
Status

Compile Error

./Main.java:23: error: ';' expected
        else{break}
                  ^
1 error