# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384965 | Ahmadsm2005 | Carnival Tickets (IOI20_tickets) | C++14 | 5 ms | 876 KiB |
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 "grader.cpp"
#include "tickets.h"
using namespace std;
long long find_maximum(int k,vector<vector<int>> x) {
int n = x.size();
long long CNT=0;
int m = x[0].size();
vector<vector<int>>answer(n);
for(int i=0;i<n;i++)
for(int l=0;l<m;l++)
answer[i].push_back(-1);
set<pair<int,pair<int,int>>>lol;
set<int>VIS;
for(int i=0;i<n;i++){
for(int l=0;l<m;l++){
lol.insert({x[i][l],{i,l}});
}
}
int Z=0;
for(int i=0;i<k;i++){
vector<int>TEMP;
int N=n;
while(N){
auto itr=lol.end(),itr2=lol.begin();
itr--;
while(VIS.find((itr->second).first)!=VIS.end())
itr--;
VIS.insert((itr->second).first);
while(VIS.find((itr2->second).first)!=VIS.end())
itr2++;
TEMP.push_back((itr->first)),TEMP.push_back((itr2->first));
answer[(itr->second).first][(itr->second).second]=Z;
VIS.insert((itr2->second).first);
answer[(itr2->second).first][(itr2->second).second]=Z;
lol.erase(itr),lol.erase(itr2);
N-=2;
}
Z++;
sort(TEMP.begin(),TEMP.end());
int X=TEMP[(TEMP.size()-1)/2];
for(int i=0;i<TEMP.size();i++){
CNT+=abs(TEMP[i]-X);
}
VIS.clear();
}
allocate_tickets(answer);
return CNT;
}
Compilation message (stderr)
# | 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... |