이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.io.*; import java.util.*;
public class tickets {
public static class Pair implements Comparable<Pair>{
int val; int ind;
public Pair(int a, int b){
this.val=a; this.ind=b;
}
public int compareTo(Pair other){
if(this.val<other.val)return -1;
if(this.val>other.val)return 1;
if(this.ind>other.ind)return -1;
return 1;
}
}
public static long find_maximum(int k, int[][] x){
long ans=0;
PriorityQueue<Pair> pq=new PriorityQueue<>();
int n=x.length; int m=x[0].length;
int[] lp=new int[n]; // rp = (N-1) - i + lp
int[][] s=new int[n][m];
for (int i = 0; i < n; i++) {
Arrays.fill(s[i],-1);
}
boolean[] b=new boolean[n];
for(int i=0;i<k;i++) {
for (int j = 0; j < n; j++) {
ans+=x[j][m-1-i+lp[j]];
pq.add(new Pair(x[j][lp[j]]+x[j][m-1-i+lp[j]],j));
}
b=new boolean[n];
for (int j = 0; j < n/2; j++) {
Pair p=pq.poll();
ans-=p.val; s[p.ind][lp[p.ind]]=i;
lp[p.ind]++; b[p.ind]=true;
}
pq=new PriorityQueue<>();
for (int j = 0; j < n; j++) {
if(!b[j]){
s[j][m-1-i+lp[j]]=i;
}
}
}
grader.allocate_tickets(s);
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |