-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathacm2.java
More file actions
39 lines (30 loc) · 701 Bytes
/
acm2.java
File metadata and controls
39 lines (30 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
public class acm2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int problems = scan.nextInt();
int n = scan.nextInt();
ArrayList<Integer> nums = new ArrayList<>(problems);
for (int i = 0; i < problems; i++)
nums.add(scan.nextInt());
int problemN = nums.remove(n);
Collections.sort(nums);
nums.add(0 , problemN);
int time = 300;
int solves = 0;
int penalty = 0;
while (!nums.isEmpty())
{
int currProblem = nums.remove(0);
time -= currProblem;
if (time < 0)
break;
solves++;
penalty += 300 - time;
}
System.out.println(solves + " " + penalty);
scan.close();
}
}