이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |