# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434240 | ioi | Carnival Tickets (IOI20_tickets) | C++14 | 1 ms | 332 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 <vector>
#include<bits/stdc++.h>
using namespace std ;
const int N = 2000 ;
vector<int> arr0[N] , arr1[N] ;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size() , m = x[0].size();
vector<vector<int> > ans(n , vector<int> (m , -1));
//allocate_tickets(ans);
long long b ;
for(int i = 0 ; i < n; i ++){
for(int j = 0 ; j < m ; j ++){
if(x[i][j] == 1)arr1[i].push_back(j);
else arr0[i].push_back(j);
}
}
long long ret = 0 ;
for(int kk = 0 ; kk < k ;kk++){
// try 0
int sum = 0 ;
bool ok = true ;
for(int i = 0 ; i < n && ok; i++){
if(arr0[i].size() == 0)
ok = false ;
}
if(ok){
for(int i = 0 ; i < n ; i ++)
ans[i][arr0[i].back()] = kk , arr0[i].pop_back() ;
continue ;
}
ok = true ;
for(int i = 0 ; i < n && ok ; i ++){
if(arr1[i].size() == 0)
ok = false ;
}
if(ok){
for(int i = 0 ; i < n ; i ++)
ans[i][arr1[i].back()] = kk , arr1[i].pop_back();
continue ;
}
for(int i = 0 ; i < n ; i ++){
if(arr0[i].empty())
sum ++ ;
}
int add = min(sum , n - sum);
ret += add ;
add = (add == sum ? 0 : 1);
for(int i = 0 ; i < n ; i ++){
if(arr0[i].empty()){
ans[i][arr1[i].back()] = kk ;
arr1[i].pop_back();
}
else {
ans[i][arr0[i].back()] = kk ;
arr0[i].pop_back();
}
}
}
allocate_tickets(ans);
return ret ;
/*
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
if (j < k) {
row[j] = j;
} else {
row[j] = -1;
}
}
answer.push_back(row);
}
allocate_tickets(answer);
return 1;
*/
}
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... |