Submission #1230843

#TimeUsernameProblemLanguageResultExecution timeMemory
1230843PlayVoltz카니발 티켓 (IOI20_tickets)C++20
27 / 100
372 ms92616 KiB
#include "tickets.h" #include <bits/stdc++.h> //#include "bits_stdc++.h" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define f first #define s second #define pb push_back #define mp make_pair #define lb lower_bound #define ub upper_bound #define input(x) scanf("%lld", &x); #define input2(x, y) scanf("%lld%lld", &x, &y); #define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z); #define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a); #define print(x, y) printf("%lld%c", x, y); #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; #define all(x) x.begin(), x.end() #define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); #define FOR(i, x, n) for (ll i =x; i<=n; ++i) #define RFOR(i, x, n) for (ll i =x; i>=n; --i) using namespace std; mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count()); //using namespace __gnu_pbds; //#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> //#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> typedef long long ll; typedef long double ld; typedef pair<ld, ll> pd; typedef pair<string, ll> psl; typedef pair<ll, ll> pi; typedef pair<pi, ll> pii; typedef pair<pi, pi> piii; void allocate_tickets( std::vector<std::vector<int> > _x); long long find_maximum(int k, std::vector<std::vector<int> > d) { ll ans = 0; ll n = d.size(), m = d[0].size(); vector<vector<int> > ret(n, vector<int> (m,-1)); vector<vector<pi> > d2(n); for (ll i=0; i<n; ++i) { for (ll j=0; j<m; ++j) d2[i].pb(mp(d[i][j], j)); sort(all(d2[i])); for (ll j=0; j<k; ++j) {ans-= d2[i][j].f; ret[i][d2[i][j].s] = j;} } //show(1); vector<ll> l(n, k-1), r(n, m-1); priority_queue<pi> pq; for (ll i=0; i<n; ++i) pq.push(mp(d2[i][l[i]].f + d2[i][r[i]].f, i)); //show(3); for (ll i=0; i<k*n/2; ++i) { //show(i); pi now = pq.top(); pq.pop(); ans += now.f; if (l[now.s]!=r[now.s]) { ret[now.s][d2[now.s][r[now.s]].s] = ret[now.s][d2[now.s][l[now.s]].s]; ret[now.s][d2[now.s][l[now.s]].s] = -1; } //show(i); l[now.s]--; r[now.s]--; if (l[now.s] >= 0) pq.push(mp(d2[now.s][l[now.s]].f + d2[now.s][r[now.s]].f, now.s)); } 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...