# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397736 | leinad2 | Carnival Tickets (IOI20_tickets) | C++17 | 1237 ms | 113876 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"tickets.h"
#include<bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int> > x)
{
int n=x.size();int m=x[0].size();int i, j;
vector<pair<int, pair<int, int> > >v;
vector<vector<int> >chk;
chk.resize(n);
for(i=0;i<n;i++)chk[i].resize(m);
vector<int>zero[1510], one[1510];
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
v.push_back({x[i][j], {i, j}});
}
}
sort(v.begin(), v.end());
long long ans=0;
for(i=0;i<v.size();i++)
{
if(2*i<v.size())ans-=v[i].first;
else ans+=v[i].first,chk[v[i].second.first][v[i].second.second]=1;
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
(chk[i][j]==0?zero:one)[i].push_back(j);
}
}
vector<vector<int> >res;
res.resize(n);
for(i=0;i<n;i++)
{
res[i].resize(m);
for(j=0;j<m;j++)res[i][j]=-1;
}
for(j=0;j<m;j++)
{
vector<pair<int, int> >v;
for(i=0;i<n;i++)v.push_back({one[i].size(), i});
sort(v.begin(), v.end());
for(i=0;i<v.size();i++)
{
if(2*i<v.size())
{
int a=v[i].second;
int b=zero[a].back();
zero[a].pop_back();
res[a][b]=j;
}
else
{
int a=v[i].second;
int b=one[a].back();
one[a].pop_back();
res[a][b]=j;
}
}
}
allocate_tickets(res);
return ans;
}
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... |