Submission #580497

#TimeUsernameProblemLanguageResultExecution timeMemory
580497joelauCarnival Tickets (IOI20_tickets)C++14
0 / 100
204 ms54296 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long A[1005], B[1005]; pair<long long,long long> lst[1005]; long long find_maximum(int k, vector<vector<int>> x) { long long N = x.size(), M = x[0].size(); memset(A,0,sizeof(A)); memset(B,0,sizeof(B)); for (long long i = 0; i < N; ++i) { lst[i] = make_pair(0,i); for (long long j = 0; j < M; ++j) lst[i].first += x[i][j]; while (B[i] < M && x[i][B[i]] == 0) B[i]++; } long long val = 0; vector< vector<int> > ans (N, vector<int>(M,-1)); for (long long i = 0; i < k; ++i) { sort(lst,lst+N); for (long long j = 0; j < N/2; ++j) { long long n = lst[j].second; if ((A[n] < M && x[n][A[n]] == 0) || B[n] >= M) ans[n][A[n]] = i, A[n]++; else ans[n][B[n]] = i, B[n]++, val--, lst[j].first--; } for (long long j = N/2; j < N; ++j) { long long n = lst[j].second; if (B[n] < M) ans[n][B[n]] = i, B[n]++, val++, lst[j].first--; else ans[n][A[n]] = i, A[n]++; } } allocate_tickets(ans); return val; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...