File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-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 boj23843 {
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+ Integer [] t = new Integer [N ];
17+ PriorityQueue<Integer > pq = new PriorityQueue<> ();
18+ nextLine();
19+ for (int i = 0 ; i < N ; i++ ) t[i] = nextInt();
20+ Arrays . sort(t);
21+ for (int i = 0 ; i < M ; i++ ) {
22+ pq. add(0 );
23+ }
24+ for (int i = N - 1 ; i >= 0 ; i-- ) {
25+ int tmp = pq. poll() + t[i];
26+ pq. add(tmp);
27+ }
28+ while (! pq. isEmpty()) {
29+ answer = Math . max(pq. poll(), answer);
30+ }
31+ System . out. println(answer);
32+ }
33+ }
34+ ```
You can’t perform that action at this time.
0 commit comments