Submission #827544

#TimeUsernameProblemLanguageResultExecution timeMemory
827544minhcoolCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms212 KiB
//#define local #ifndef local #include "tickets.h" #endif #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<ll, ll> ii; typedef pair<ii, ll> iii; typedef pair<ii, ii> iiii; const ll N = 3e5 + 5; const ll oo = 1e18 + 7, mod = 1e9 + 7; mt19937 rng(1); ll rnd(ll l, ll r){ ll temp = rng() % (r - l + 1); return abs(temp) + l; } ll n, m, itr[N]; ll find_maximum(int k, vector<vector<int>> x){ n = x.size(), m = x[0].size(); ll sum = 0; ll ans = 0; for(ll i = 0; i < n; i++){ for(ll j = 0; j < k; j++) ans += (ll)x[i][m - j - 1]; itr[i] = 0; } priority_queue<ii, vector<ii>> pq; for(ll i = 0; i < n; i++) pq.push({-((ll)x[i][0] + x[i][m - k]), i}); for(ll i = 1; i <= (n * k)/2; i++){ ii temp = pq.top(); pq.pop(); itr[temp.se]++; ans += temp.fi; if(itr[temp.se] < k) pq.push({-((ll)x[temp.se][itr[temp.se]] + x[temp.se][m - k + itr[temp.se]]), temp.se}); } vector<vector<int>> assign; assign.resize(n); for(ll i = 0; i < n; i++){ assign[i].resize(m); for(ll j = 0; j < m; j++) assign[i][j] = -1; ll cnt = 0; for(ll j = 0; j < itr[i]; j++){ assign[i][j] = cnt; cnt++; } for(ll j = itr[i]; j < k; j++){ assign[i][m - k + j] = cnt; cnt++; } } allocate_tickets(assign); return sum; } #ifdef local void process(){ } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll t; cin >> t; while(t--) process(); } #endif
#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...