# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630607 |
2022-08-16T16:05:07 Z |
kyaruru |
Schools (IZhO13_school) |
Java 11 |
|
2000 ms |
51592 KB |
import java.io.*;
import java.util.*;
public class school {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
PriorityQueue<int[]> aa=new PriorityQueue<>((o1, o2) -> o2[0]-o1[0]);
PriorityQueue<int[]> bb=new PriorityQueue<>((o1, o2) -> o2[1]-o1[1]);
String[] s=bf.readLine().split(" ");
int a=Integer.parseInt(s[0]),p=Integer.parseInt(s[1]),q=Integer.parseInt(s[2]);
boolean[] use=new boolean[a];
for(int i=0; i<a; i++){
s=bf.readLine().split(" ");
int x=Integer.parseInt(s[0]),y=Integer.parseInt(s[1]);
aa.add(new int[]{x,y,i});
bb.add(new int[]{x,y,i});
}
int[][] ka=new int[p+q][2];
int i=0;
while(i<p+q){
while(use[aa.peek()[2]]) aa.poll();
while(use[bb.peek()[2]]) bb.poll();
int[] r;
if(q==0 || aa.peek()[0]>bb.peek()[1]) r = aa.poll();
else r = bb.poll();
ka[i][0]=r[0];
ka[i][1]=r[1];
use[r[2]]=true;
i++;
}
Arrays.sort(ka,(o1, o2) -> (o2[0]-o2[1])-(o1[0]-o1[1]));
i=0;
long sum=0;
for(; i<p; i++) sum+=ka[i][0];
for(; i<p+q; i++) sum+=ka[i][1];
System.out.println(sum);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
9200 KB |
Output is correct |
2 |
Correct |
68 ms |
8980 KB |
Output is correct |
3 |
Correct |
71 ms |
8716 KB |
Output is correct |
4 |
Incorrect |
80 ms |
8740 KB |
Output isn't correct |
5 |
Incorrect |
77 ms |
9036 KB |
Output isn't correct |
6 |
Incorrect |
78 ms |
9072 KB |
Output isn't correct |
7 |
Incorrect |
261 ms |
14556 KB |
Output isn't correct |
8 |
Correct |
537 ms |
15504 KB |
Output is correct |
9 |
Incorrect |
417 ms |
15100 KB |
Output isn't correct |
10 |
Incorrect |
561 ms |
15228 KB |
Output isn't correct |
11 |
Incorrect |
528 ms |
15400 KB |
Output isn't correct |
12 |
Incorrect |
487 ms |
15228 KB |
Output isn't correct |
13 |
Incorrect |
1232 ms |
20228 KB |
Output isn't correct |
14 |
Incorrect |
1111 ms |
24748 KB |
Output isn't correct |
15 |
Incorrect |
908 ms |
31212 KB |
Output isn't correct |
16 |
Correct |
1543 ms |
36420 KB |
Output is correct |
17 |
Execution timed out |
2051 ms |
41268 KB |
Time limit exceeded |
18 |
Incorrect |
1819 ms |
45176 KB |
Output isn't correct |
19 |
Execution timed out |
2059 ms |
49928 KB |
Time limit exceeded |
20 |
Execution timed out |
2075 ms |
51592 KB |
Time limit exceeded |