This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.util.Arrays;
public class tickets {
private class TicketsWithColors {
int color;
int[] val;
TicketsWithColors(int color, int[] val) {
this.color = color;
this.val = val;
}
}
long find_maximum(int k, int[][] x) {
int n = x.length;
int m = x[0].length;
int[][] answer = new int[n][m];
TicketsWithColors[] t = new TicketsWithColors[n];
for (int i = 0; i < n; i++) {
t[i] = new TicketsWithColors(i, x[i]);
}
Arrays.sort(t, (t1, t2) -> t1.val[0] + t1.val[m - 1] - t2.val[0] - t2.val[m - 1]);
long ans = 0;
for (int i = 0; i < n; i++) Arrays.fill(answer[i], -1);
for (int i = 0; i < n; i++) {
int col = t[i].color;
if (i < n / 2) {
answer[col][0] = 0;
ans -= t[i].val[0];
} else {
answer[col][m - 1] = 0;
ans += t[i].val[m - 1];
}
}
grader.allocate_tickets(answer);
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... |