Submission #1062786

#TimeUsernameProblemLanguageResultExecution timeMemory
1062786jerzykCarnival Tickets (IOI20_tickets)C++17
27 / 100
355 ms72804 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; #define pb push_back #define st first #define nd second typedef long long ll; typedef long double ld; const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL; const int II = 2 * 1000 * 1000 * 1000; const ll M = 1000LL * 1000LL * 1000LL + 7LL; const int N = 1500 + 7; vector<pair<int, pair<int, int>>> kol; vector<vector<int>> gam; vector<int> lft[N][2]; int il[N]; bool Cp(int a, int b) { int x = max(lft[a][0].size(), lft[a][1].size()); int y = max(lft[b][0].size(), lft[b][1].size()); return (x > y); } void DoAns(int n, int m, int k) { vector<int> ord; for(int i = 0; i < n; ++i) { ord.pb(i); for(int j = 0; j < k - il[i]; ++j) lft[i][0].pb(j); for(int j = m - il[i]; j < m; ++j) lft[i][1].pb(j); } sort(ord.begin(), ord.end(), Cp); for(int l = 0; l < k; ++l) { int ilu = 0, ild = 0; for(int i = 0; i < n; ++i) { int v = ord[i]; if(lft[v][0].size() > lft[v][1].size() || (lft[v][0].size() == lft[v][1].size() && ilu < ild)) { ++ilu; gam[v][lft[v][0].back()] = l; lft[v][0].pop_back(); }else { ++ild; gam[v][lft[v][1].back()] = l; lft[v][1].pop_back(); } } } } ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(), m = x[0].size(); gam = x; ll answer = 0LL; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) gam[i][j] = -1; for(int j = 0; j < k; ++j) answer -= x[i][j]; for(int j = 0; j < k; ++j) kol.pb(make_pair(x[i][k - j - 1] + x[i][m - j - 1], make_pair(i, j + 1))); } sort(kol.begin(), kol.end()); reverse(kol.begin(), kol.end()); //cerr << answer << "\n"; for(int i = 0; i < (n * k) / 2; ++i) { il[kol[i].nd.st] = kol[i].nd.nd; answer += (ll)kol[i].st; //cerr << i << " " << answer << " " << kol[i].st << "\n"; } DoAns(n, m, k); allocate_tickets(gam); return answer; }
#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...