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 long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
// #define int long long
#define ll long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 1600;
int n, m, q0[maxn], q1[maxn], l[maxn], r[maxn];
long long find_maximum (int k, std::vector<std::vector<int>> x) {
n = x.size();
m = x[0].size();
//em cada uma das k vezes eu vou colocar n/2 0 e 1
//tiro os 0
vector<vector<int>> s(n);
int ans = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
s[i].pb(-1);
if(x[i][j] == 0) q0[i]++;
else q1[i]++;
}
l[i] = 0;
r[i] = m-1;
}
for(int j = 0; j < k; j++) {
int qtd0 = 0;
int qtd1 = 0;
vector<pair<int,int>> v0;
for(int i = 0; i < n; i++) {
v0.pb(mp(q0[i],i));
}
sort(all(v0),greater<pair<int,int>>());
for(auto X : v0) {
int id = X.sc;
if(qtd0 >= n/2 && q1[id] > 0) {
q1[id]--;
qtd1++;
s[id][r[id]] = j;
r[id]--;
}
else {
qtd0++;
q0[id]--;
s[id][l[id]] = j;
l[id]++;
}
}
ans+= min(qtd1,qtd0);
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cout << s[i][j] << " ";
}cout << endl;
}
// allocate_tickets(s);
return ans;
}
// int32_t main() {
// ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// // freopen("out.out", "w", stdout);
// int N,M,K; cin >> N >> M >> K;
// vector<vector<int>> x(N);
// for(int i = 0; i < N; i++) {
// for(int j = 0; j < M; j++) {
// int o; cin >> o;
// x[i].pb(o);
// }
// }
// cout << find_maximum(K,x);
// }
# | 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... |