Submission #305170

#TimeUsernameProblemLanguageResultExecution timeMemory
305170VimmerCarnival Tickets (IOI20_tickets)C++14
27 / 100
733 ms51448 KiB
#include <bits/stdc++.h> #include "tickets.h" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define N 1005 #define PB push_back #define sz(x) int(x.size()) #define P 31 #define F first #define M ll(1e9 + 7) #define S second #define all(x) x.begin(), x.end() #define endl '\n' //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") using namespace std; //using namespace __gnu_pbds; typedef long long ll; //typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ll mlt(ll a, ll b) {return (a * b) % M;} ll sm(ll a, ll b) {return (a + b) % M;} ll find_maximum(int k, vector<vector<int> > x) { int n = sz(x); int m = sz(x[0]); vector <vector <int> > r; r.resize(n); pair <int, int> pos[n]; for (int i = 0; i < n; i++) { pos[i] = {0, m - 1}; r[i].resize(m, -1); } ll ans = 0; set <pair <int, int> > se; se.clear(); for (int i = 0; i < n; i++) se.insert({x[i][0] + x[i][m - 1], i}); for (int u = 0; u < k; u++) { set <pair <int, int> > st = se; se.clear(); int i = 0; ll sum = 0; while (sz(st) > 0) { int nm = (*st.begin()).S; st.erase(st.begin()); if (i < n / 2) sum -= x[nm][pos[nm].F++], r[nm][pos[nm].F - 1] = u; else sum += x[nm][pos[nm].S--], r[nm][pos[nm].S + 1] = u; se.insert({x[nm][pos[nm].F] + x[nm][pos[nm].S], nm}); i++; } ans += sum; } allocate_tickets(r); 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...