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 DIM 2000
using namespace std;
int n,m;
int f[DIM];
long long find_maximum (int k, vector<vector<int> > x){
n = x.size(), m = x[0].size();
int i;
vector <pair<int,int> > v;
vector <vector<int> > ans,ans2;
ans.resize(n); ans2.resize(n);
for (i=0;i<n;i++)
ans[i].resize(m,-1), ans2[i].resize(m,-1);
/// fie le iau pe cele mai mici n/2 la inceput, fie pe cele mai mari
for (i=0;i<n;i++)
v.push_back(make_pair(x[i][0],i));
sort (v.begin(),v.end());
long long sum = 0;
for (i=0;i<n/2;i++){
sum -= v[i].first;
f[v[i].second] = 1;
ans[v[i].second][0] = 0;
}
for (i=0;i<n;i++)
if (!f[i]){
sum += x[i].back();
ans[i][m-1] = 0;
}
/// iau maxime
v.clear();
memset (f,0,sizeof f);
for (i=0;i<n;i++)
v.push_back(make_pair(x[i].back(),i));
sort (v.begin(),v.end());
reverse (v.begin(),v.end());
long long sum2 = 0;
for (i=0;i<n/2;i++){
sum2 += v[i].first;
f[v[i].second] = 1;
ans2[v[i].second][m-1] = 0;
}
for (i=0;i<n;i++)
if (!f[i]){
sum2 -= x[i][0];
ans2[i][0] = 0;
}
if (sum2 > sum){
sum = sum2;
ans = ans2;
}
allocate_tickets(ans);
return sum;
}
# | 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... |