# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630559 |
2022-08-16T14:12:34 Z |
kyaruru |
Schools (IZhO13_school) |
Java 11 |
|
2000 ms |
29652 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));
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) -> Math.abs(o2[0]-o2[1])-Math.abs(o1[0]-o1[1]));
long sum=0;
int c=p+q;
for(int i=0; i<c; i++){
if(p==0){
sum+=ka[i][1];
q--;
}
else if(q==0){
sum+=ka[i][0];
p--;
}
else{
if(ka[i][0]>ka[i][1]){
sum+=ka[i][0];
p--;
}
else{
sum+=ka[i][1];
q--;
}
}
}
System.out.println(sum);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
8860 KB |
Output is correct |
2 |
Correct |
64 ms |
8940 KB |
Output is correct |
3 |
Correct |
68 ms |
9020 KB |
Output is correct |
4 |
Incorrect |
67 ms |
9020 KB |
Output isn't correct |
5 |
Incorrect |
73 ms |
8984 KB |
Output isn't correct |
6 |
Incorrect |
79 ms |
8924 KB |
Output isn't correct |
7 |
Incorrect |
513 ms |
15068 KB |
Output isn't correct |
8 |
Correct |
699 ms |
15776 KB |
Output is correct |
9 |
Incorrect |
688 ms |
15604 KB |
Output isn't correct |
10 |
Incorrect |
634 ms |
15524 KB |
Output isn't correct |
11 |
Incorrect |
633 ms |
15304 KB |
Output isn't correct |
12 |
Incorrect |
683 ms |
15704 KB |
Output isn't correct |
13 |
Incorrect |
1096 ms |
17232 KB |
Output isn't correct |
14 |
Incorrect |
1229 ms |
19652 KB |
Output isn't correct |
15 |
Incorrect |
1379 ms |
21432 KB |
Output isn't correct |
16 |
Correct |
1614 ms |
27692 KB |
Output is correct |
17 |
Incorrect |
1852 ms |
29328 KB |
Output isn't correct |
18 |
Incorrect |
1960 ms |
28676 KB |
Output isn't correct |
19 |
Execution timed out |
2009 ms |
27676 KB |
Time limit exceeded |
20 |
Execution timed out |
2057 ms |
29652 KB |
Time limit exceeded |