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 <vector>
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;
long long find_maximum(int k, vector<vector<int>> X) {
int n = X.size();
int m = X[0].size();
ll res1 = 0;
vector < int > ls( m , m - 1 ) , st( m , 0 );
vector < vector < int > > ans( n , vector < int > (m , -1) );
for( int it = 0; it < k; it++ ){
vector < pair < ll , int > > res;
ll cnt = 0;
for( int i = 0; i < n; i++ ){
res.push_back({ -X[i][st[i]] - X[i][ls[i]] , i });
cnt += X[i][ls[i]];
}
sort( res.rbegin() , res.rend() );
for( int i = 0; i < n / 2; i++ ){
ans[res[i].se][st[res[i].se]++] = it;
cnt += res[i].fi;
}
for( int i = n / 2; i < n; i++ ){
ans[res[i].se][ls[res[i].se]--] = it;
}
res1 += cnt;
}
allocate_tickets( ans );
return res1;
}
# | 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... |