# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
819909 | Abrar_Al_Samit | Carnival Tickets (IOI20_tickets) | C++17 | 1 ms | 340 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;
const int nax = 1500;
int n, m;
int cnt[nax][2];
vector<int>pz[nax], po[nax];
int ptr[nax][2];
long long find_maximum(int k, vector<vector<int>> x) {
n = x.size();
m = x[0].size();
for(int i=0; i<n; ++i) {
for(int j=0; j<m; ++j) {
if(x[i][j]==1) {
po[i].push_back(j);
} else {
pz[i].push_back(j);
}
}
}
vector<vector<int>>ans(n, vector<int>(m, -1));
for(int i=0; i<n; ++i) {
for(int j=0; j<k; ++j) {
if(cnt[j][0] < n/2 && pz[i].size()>ptr[i][0]) {
++cnt[j][0];
ans[i][pz[i][ptr[i][0]]] = j;
++ptr[i][0];
} else if(cnt[j][1] < n/2 && po[i].size()>ptr[i][1]) {
++cnt[j][1];
ans[i][po[i][ptr[i][1]]] = j;
++ptr[i][1];
} else if(pz[i].size()>ptr[i][0]) {
++cnt[j][0];
ans[i][pz[i][ptr[i][0]]] = j;
++ptr[i][0];
} else {
++cnt[j][1];
ans[i][po[i][ptr[i][1]]] = j;
++ptr[i][1];
}
}
}
int mx_ans = 0;
for(int i=0; i<k; ++i) {
mx_ans += min(cnt[i][0], cnt[i][1]);
}
allocate_tickets(ans);
return mx_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... |