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"
#define DIMN 1510
using namespace std;
pair <int , int> v[DIMN] , w[DIMN];
int f[DIMN];
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size() , i , pv , pw;
int m = x[0].size();
long long sol = 0;
vector<vector<int>> answer;
for (i = 0; i < n; i++) {
vector<int> row;
row.resize(m , -1);
answer.push_back(row);
}
if (m == 1){
for (i = 0 ; i < n ; i++){
answer[i][0] = 0;
v[i] = make_pair(x[i][0] , i);
}
sort (v , v + n);
for (i = 0 ; i < n ; i++){
if (i < n / 2)
sol = sol - v[i].first;
else
sol = sol + v[i].first;
}
}
if (k == 1){
for (i = 0 ; i < n ; i++){
v[i] = make_pair(x[i][0] , i);
w[i] = make_pair(x[i].back() , i);
}
sort (v , v + n);
sort (w , w + n);
pv = 0;
pw = n - 1;
for (i = 0 ; i < n / 2 ; i++){
while (f[v[pv].second] == 1)
pv++;
answer[v[pv].second][0] = 0;
f[v[pv].second] = 1;
sol -= v[pv].first;
pv++;
while (f[w[pw].second] == 1)
pw--;
answer[w[pw].second][m - 1] = 0;
f[w[pw].second] = 1;
sol += w[pw].first;
pw--;
}
}
allocate_tickets(answer);
return sol;
}
# | 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... |