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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
deque<deque<int>> r;
int n, m;
long long find_maximum(int k, vector<vector<int>>rrrr){
n = rrrr.size(), m = rrrr[0].size();
for(int i = 0; i < n; i++){
r.pb({});
for(int j = 0; j < m; j++) r[i].pb(rrrr[i][j]);
}
ll s = 0;
vector <vector<int>> ans(n, vector<int>(m, -1));
for(int i = 0; i < m; i++){
vector <ll> v;
for(int j = 0; j < n; j++){
if(j%2 == 0){
v.pb(r[j].front());
r[j].pop_front();
ans[j][i] = i;
}
else{
v.pb(r[j].back());
r[j].pop_back();
ans[j][m - i - 1] = i;
}
}
sort(v.begin(), v.end());
ll b = (v[n/2] + v[n/2 - 1])/2;
for(ll x: v) s+=abs(x - b);
}
allocate_tickets(ans);
return s;
}
# | 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... |