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));
String[] s=bf.readLine().split(" ");
int a=Integer.parseInt(s[0]),p=Integer.parseInt(s[1]),q=Integer.parseInt(s[2]);
int[][] k=new int[a][2];
for(int i=0; i<a; i++){
s=bf.readLine().split(" ");
k[i][0]=Integer.parseInt(s[0]);
k[i][1]=Integer.parseInt(s[1]);
}
Arrays.sort(k,(o1, o2) -> {
if(Math.max(o1[0],o1[1])==Math.max(o2[0],o2[1])) return Math.min(o2[0],o2[1])-Math.min(o1[0],o1[1]);
else return Math.max(o2[0],o2[1])-Math.max(o1[0],o1[1]);
});
int[][] ka=new int[p+q][2];
System.arraycopy(k, 0, ka, 0, p + q);
Arrays.sort(ka,(o1, o2) -> (o2[0]-o2[1])-(o1[0]-o1[1]));
int 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);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
9376 KB |
Output is correct |
2 |
Correct |
65 ms |
8868 KB |
Output is correct |
3 |
Correct |
78 ms |
8948 KB |
Output is correct |
4 |
Incorrect |
65 ms |
9164 KB |
Output isn't correct |
5 |
Incorrect |
71 ms |
9008 KB |
Output isn't correct |
6 |
Incorrect |
75 ms |
8868 KB |
Output isn't correct |
7 |
Incorrect |
521 ms |
15420 KB |
Output isn't correct |
8 |
Correct |
679 ms |
15824 KB |
Output is correct |
9 |
Incorrect |
626 ms |
15380 KB |
Output isn't correct |
10 |
Incorrect |
673 ms |
15676 KB |
Output isn't correct |
11 |
Incorrect |
679 ms |
15772 KB |
Output isn't correct |
12 |
Incorrect |
723 ms |
15956 KB |
Output isn't correct |
13 |
Incorrect |
1080 ms |
17796 KB |
Output isn't correct |
14 |
Incorrect |
1234 ms |
20464 KB |
Output isn't correct |
15 |
Incorrect |
1308 ms |
23164 KB |
Output isn't correct |
16 |
Correct |
1469 ms |
27356 KB |
Output is correct |
17 |
Incorrect |
1901 ms |
31760 KB |
Output isn't correct |
18 |
Incorrect |
1886 ms |
31420 KB |
Output isn't correct |
19 |
Incorrect |
1978 ms |
30848 KB |
Output isn't correct |
20 |
Execution timed out |
2021 ms |
33280 KB |
Time limit exceeded |