File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed
Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.* ;
4+
5+ public class boj23254 {
6+ static BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
7+ static StringTokenizer st;
8+ static void nextLine () throws Exception {st = new StringTokenizer (br .readLine ());}
9+ static int nextInt() {return Integer . parseInt(st. nextToken());}
10+
11+ public static void main(String [] args) throws Exception {
12+ nextLine();
13+ int N = nextInt();
14+ int M = nextInt();
15+ int answer = 0 ;
16+ int [] base = new int [M ];
17+ int [] up = new int [M ];
18+ int time = 24 * N ;
19+ PriorityQueue<Node > pq = new PriorityQueue<> (
20+ (x,y) - > y. plus - x. plus
21+ );
22+ nextLine();
23+ for (int i = 0 ; i < M ; i++ ) {
24+ base[i] = nextInt();
25+ answer += base[i];
26+ }
27+ nextLine();
28+ for (int i = 0 ; i < M ; i++ ) {
29+ up[i] = nextInt();
30+ pq. add(new Node (100 - base[i], up[i]));
31+ }
32+
33+ while (! pq. isEmpty()){
34+ Node cur = pq. poll();
35+
36+ if (time >= (cur. rest / cur. plus)){
37+ time -= cur. rest / cur. plus;
38+
39+ answer += cur. plus * (cur. rest / cur. plus);
40+
41+ if (cur. rest % cur. plus >= 1 ){
42+ pq. add(new Node (cur. rest % cur. plus,cur. rest % cur. plus));
43+ }
44+ }else if (time > 0 && (cur. rest >= time * cur. plus)){
45+ answer += time * cur. plus;
46+ time = 0 ;
47+ }
48+ }
49+
50+ System . out. println(answer);
51+ }
52+ static class Node {
53+ int rest;
54+ int plus;
55+
56+ Node (int rest ,int plus ){
57+ this . rest = rest;
58+ this . plus = plus;
59+ }
60+ }
61+ }
62+ ```
You can’t perform that action at this time.
0 commit comments