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"
using namespace std;
int Wziety[1509];
long long find_maximum(int k, vector<vector<int>>A)
{
int n = A.size();
int n2=n/2;
int m = A[0].size();
vector<vector<int>>answer(n,vector<int>(m,-1));
vector<deque<pair<int,int>>>D;
for(vector<int>U : A)
{
deque<pair<int,int>>T;
for(int i=0;i<(int)U.size();i++)
{
T.push_back({U[i],i});
}
sort(T.begin(),T.end());
D.push_back(T);
}
memset(Wziety,-1,sizeof(Wziety));
long long wynik=0;
for(int i=0;i<k;i++)
{
vector<pair<int,int>>Opty;
for(int j=0;j<n;j++)
{
Opty.push_back({D[j].front().first+D[j].back().first,j});
}
sort(Opty.begin(),Opty.end());
for(int j=0;j<n2;j++)
{
Wziety[Opty[j].second]=i;
}
for(int j=0;j<n;j++)
{
if(Wziety[j]==i)
{
answer[j][D[j].front().second]=i;
wynik-=D[j].front().first;
D[j].pop_front();
}
else
{
answer[j][D[j].back().second]=i;
wynik+=D[j].back().first;
D[j].pop_back();
}
}
}
allocate_tickets(answer);
return wynik;
}
# | 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... |