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 <bits/stdc++.h>
#include "tickets.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pi = pair<ll, pair<ll, ll>>;
using ii = pair<int, int>;
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll find_maximum(int K, vector<vector<int>> A) {
int N = A.size(), M = A[0].size(); ll res = 0;
vector<vector<int>> S(N, vector<int> (M, -1));
int lf[N], rf[N];
for(int l = 0; l < N; l++)
lf[l] = 0, rf[l] = M - 1;
for(int R = 0; R < K; R++) {
vector<pair<ll, ll>> arr;
for(int l = 0; l < N; l++) {
res += A[l][rf[l]]; S[l][rf[l]] = R;
arr.pb({A[l][lf[l]] + A[l][rf[l]], l});
rf[l]--;
}
sort(arr.begin(), arr.end());
for(int l = 0; l < N / 2; l++) {
rf[arr[l].ss]++; res -= arr[l].ff;
S[arr[l].ss][rf[arr[l].ss]] = -1;
S[arr[l].ss][lf[arr[l].ss]] = R; lf[arr[l].ss]++;
}
}
allocate_tickets(S);
return res;
}
# | 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... |