Submission #3769874
Source Code Expand
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int x = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } Arrays.sort(a); int happy = 0; for (int j = 0; j < n; j++) { x = x - a[j]; if (x < 0) { break; } else { happy++; } } if (x > 0) { happy--; } System.out.println(happy); } }
Submission Info
Submission Time | |
---|---|
Task | A - Candy Distribution Again |
User | ks96neko |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 713 Byte |
Status | AC |
Exec Time | 111 ms |
Memory | 23764 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 96 ms | 18772 KB |
0_01.txt | AC | 97 ms | 21844 KB |
0_02.txt | AC | 97 ms | 22612 KB |
0_03.txt | AC | 96 ms | 19284 KB |
1_00.txt | AC | 111 ms | 18644 KB |
1_01.txt | AC | 101 ms | 18004 KB |
1_02.txt | AC | 105 ms | 19284 KB |
1_03.txt | AC | 103 ms | 23764 KB |
1_04.txt | AC | 111 ms | 21204 KB |
1_05.txt | AC | 104 ms | 19028 KB |
1_06.txt | AC | 103 ms | 21076 KB |
1_07.txt | AC | 104 ms | 21584 KB |