Submission #307519

#TimeUsernameProblemLanguageResultExecution timeMemory
307519nicolaalexandraCarnival Tickets (IOI20_tickets)C++14
27 / 100
779 ms51692 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]; long long find_maximum (int k, vector<vector<int> > x){ n = x.size(), m = x[0].size(); int i,j; vector <pair<int,int> > v; 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(); ans[idx][poz[idx].second] = ans[idx][poz[idx].first]; if (poz[idx].first != poz[idx].second) ans[idx][poz[idx].first] = -1; 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)); } 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...