Submission #428311

#TimeUsernameProblemLanguageResultExecution timeMemory
428311egekabasCarnival Tickets (IOI20_tickets)C++14
27 / 100
627 ms51648 KiB
#include "tickets.h" #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<int> curbeg(n), curfin(n); for(int i = 0; i < n; ++i){ curbeg[i] = 0; curfin[i] = m-1; } vector<vector<int>> ret(n, vector<int>(m, -1)); ll ans = 0; for(int round = 0; round < k; ++round){ vector<pii> vec; for(int i = 0; i < n; ++i) vec.pb({x[i][curbeg[i]]+x[i][curfin[i]], i}); sort(all(vec), greater<pii>()); for(int i = 0; i < n; ++i){ int idx = vec[i].ss; if(i < n/2){ ans += x[idx][curfin[idx]]; ret[idx][curfin[idx]] = round; --curfin[idx]; } else{ ans -= x[idx][curbeg[idx]]; ret[idx][curbeg[idx]] = round; ++curbeg[idx]; } } } allocate_tickets(ret); return ans; }
#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...