Submission #441107

#TimeUsernameProblemLanguageResultExecution timeMemory
441107roseanne_pcyCarnival Tickets (IOI20_tickets)C++14
14 / 100
571 ms57772 KiB
#include "tickets.h" #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef vector<int> vi; typedef long long ll; #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rsz resize const int md = 1e9+7; const ll inf = 1e18; const int maxn = 2e3+5; template<class T> void ckmin(T &a, T b) { a = min(a, b); } template<class T> void ckmax(T &a, T b) { a = max(a, b); } int zeros[maxn], ones[maxn]; int p0[maxn], p1[maxn]; int n, m; bool cmp(int x, int y) { return zeros[x]> zeros[y]; } 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++) { zeros[i] += (x[i][j] == 0); ones[i] += (x[i][j] == 1); } p1[i] = zeros[i]; } vector< vector<int> > res(n, vector<int>(m, -1)); vector<int> all_nums; for(int i = 0; i< n; i++) all_nums.pb(i); ll sum = 0; for(int r = 0; r< k; r++) { sort(all(all_nums), cmp); int minus = 0, plus = 0; for(int i = 0; i< n/2; i++) { int x = all_nums[i]; if(zeros[x]> 0) { zeros[x]--; res[x][p0[x]++] = r; } else { ones[x]--; minus++; res[x][p1[x]++] = r; } } for(int i = n/2; i< n; i++) { int x = all_nums[i]; if(ones[x]> 0) { ones[x]--; plus++; res[x][p1[x]++] = r; } else { zeros[x]--; res[x][p0[x]++] = r; } } sum += plus-minus; } allocate_tickets(res); return sum; }
#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...