Submission #307534

#TimeUsernameProblemLanguageResultExecution timeMemory
307534nicolaalexandraCarnival Tickets (IOI20_tickets)C++14
0 / 100
3 ms640 KiB
#include <bits/stdc++.h> #include "tickets.h" #define DIM 2000 #define INF 2000000000000000000LL using namespace std; int n,m; priority_queue <pair<long long,int> > h; pair <int,int> poz[DIM],v[DIM]; long long find_maximum (int k, vector<vector<int> > x){ n = x.size(), m = x[0].size(); int i,j; vector <vector<int> > ans; ans.resize(n); for (i=0;i<n;i++){ ans[i].resize(m,-1); poz[i] = make_pair (k-1,m-1); } long long sum = 0; /// le pun de la inceput pe primele k cu minus for (i=0;i<n;i++) for (j=0;j<k;j++){ sum -= x[i][j]; //ans[i][j] = j; } /// vreau sa fac jumatate din minus in plus for (i=0;i<n;i++) h.push (make_pair(x[i][poz[i].first] + x[i][poz[i].second],i)); for (i=1;i<=n*k/2;i++){ sum += h.top().first; int idx = h.top().second; h.pop(); poz[idx].first--, poz[idx].second--; if (poz[idx].first >= 0) h.push (make_pair(x[idx][poz[idx].first] + x[idx][poz[idx].second], idx)); } for (i=0;i<k;i++){ /// sortez liniile dupa ultimul element for (j=0;j<n;j++) v[j] = make_pair (poz[j].second,j); sort (v,v+n); for (j=0;j<n;j++){ int idx = v[j].second; if (j < n/2){ ans[idx][poz[idx].first] = i; poz[idx].first--; } else { ans[idx][poz[idx].second] = i; poz[idx].second++; } } } allocate_tickets(ans); return sum; }
#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...