# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
625317 | Trunkty | Carnival Tickets (IOI20_tickets) | C++14 | 685 ms | 101712 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 <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
//#define ll ll;
#include "tickets.h"
ll pick[1505][1505];
vector<ll> zero[1505],one[1505];
ll find_maximum(int k, vector<vector<int>> x) {
ll n = x.size();
ll m = x[0].size();
ll ret=0;
vector<vector<ll>> v;
for(ll i=0;i<n;i++){
for(ll j=0;j<m;j++){
if(x[i][j]==0){
zero[i].push_back(j);
}
else{
one[i].push_back(j);
}
}
v.push_back({zero[i].size(),i});
}
for(ll i=1;i<=k;i++){
sort(v.begin(),v.end());
ll cntz=0,cnto=0;
for(ll j=0;j<n/2;j++){
ll p = v[j][1];
if(one[p].size()>0){
cnto++;
pick[p][one[p].back()] = i;
one[p].pop_back();
}
else{
cntz++;
pick[p][zero[p].back()] = i;
zero[p].pop_back();
}
}
for(ll j=n/2;j<n;j++){
ll p = v[j][1];
if(zero[p].size()>0){
cntz++;
pick[p][zero[p].back()] = i;
zero[p].pop_back();
}
else{
cnto++;
pick[p][one[p].back()] = i;
one[p].pop_back();
}
}
ret += min(cntz,cnto);
v.clear();
for(ll j=0;j<n;j++){
v.push_back({zero[j].size(),j});
}
}
//
vector<vector<int>> answer;
for(ll i=0;i<n;i++) {
vector<int> row(m);
for(ll j=0;j<m;j++) {
row[j] = pick[i][j]-1;
}
answer.push_back(row);
}
allocate_tickets(answer);
return ret;
}
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... |