This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long A[1005], B[1005];
pair<long long,long long> lst[1005];
long long find_maximum(int k, vector<vector<int>> x) {
long long N = x.size(), M = x[0].size();
memset(A,0,sizeof(A)); memset(B,0,sizeof(B));
for (long long i = 0; i < N; ++i) {
lst[i] = make_pair(0,i);
for (long long j = 0; j < M; ++j) lst[i].first += x[i][j];
while (B[i] < M && x[i][B[i]] == 0) B[i]++;
}
long long val = 0;
vector< vector<int> > ans (N, vector<int>(M,-1));
for (long long i = 0; i < k; ++i) {
sort(lst,lst+N);
for (long long j = 0; j < N/2; ++j) {
long long n = lst[j].second;
if ((A[n] < M && x[n][A[n]] == 0) || B[n] >= M) ans[n][A[n]] = i, A[n]++;
else ans[n][B[n]] = i, B[n]++, val--, lst[j].first--;
}
for (long long j = N/2; j < N; ++j) {
long long n = lst[j].second;
if (B[n] < M) ans[n][B[n]] = i, B[n]++, val++, lst[j].first--;
else ans[n][A[n]] = i, A[n]++;
}
}
allocate_tickets(ans);
return val;
}
# | 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... |