Submission #309799

#TimeUsernameProblemLanguageResultExecution timeMemory
309799aZvezdaCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms384 KiB
#include "tickets.h" #include <vector> #include <vector> long long find_maximum(int k, std::vector<std::vector<int>> d); void allocate_tickets( std::vector<std::vector<int>> _x); #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" typedef long long ll; typedef long double ld; typedef unsigned long long ull; template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } const ll mod = 1e9 + 7; template<class T> inline void fix(T &x) {if(labs(x) >= mod) {x %= mod;} if(x < 0) {x += mod;}} #define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(); int m = x[0].size(); std::vector<std::vector<int> > answer; vector<vector<pair<int, int> > > pr; priority_queue<pair<int, int> > pq; vector<int> got; got.resize(n); int ans = 0; for (int i = 0; i < n; i++) { vector<int> row(m); for (int j = 0; j < m; j++) { row[j] = -1; } ans += x[i][m - 1]; pq.push({-x[i][0] - x[i][m - k], i}); answer.push_back(row); } int iter = n * k / 2; for(int i = 0; i < iter; i ++) { auto curr = pq.top(); pq.pop(); ans += curr.first; got[curr.second] ++; if(got[curr.second] < k) { pq.push({-x[curr.second][got[curr.second]] - x[curr.second][m - k + got[curr.second]], curr.second}); } } int cnt = 0; for(int i = 0; i < n; i ++) { for(int j = 0; j < got[i]; j ++) { answer[i][j] = (cnt + j) % k; } cnt += got[i]; int group = cnt; for(int j = m - k + got[i]; j < m; j ++) { answer[i][j] = group % k; group ++; } } allocate_tickets(answer); 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...