Submission #301225

#TimeUsernameProblemLanguageResultExecution timeMemory
301225naderjemelCarnival Tickets (IOI20_tickets)C++17
27 / 100
849 ms54644 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int K, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer; long long s=0; vector<int> usedi, usedj, used; for(int i=0;i<n;i++){ usedi.push_back(0); usedj.push_back(0); used.push_back(1); } answer.resize(n,vector<int>()); priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > > pq; for(int i=0;i<n;i++) for(int j = 0; j < m; j++) answer[i].push_back(-1); for(int k=0;k<K;k++){ for(int i = 0; i < n; i++){ if(used[i]==1){ pq.push({x[i][m - 1 - usedj[i]] + x[i][0 + usedi[i]], i}); used[i]=0; } } for (int i = 0; i < n; i++) { pair<int,int> fr = pq.top(); int color = fr.second; pq.pop(); used[color]=1; if (i < n / 2) { s -= x[color][usedi[color]]; answer[color][usedi[color]] = k; usedi[color]++; } else { s += x[color][m - 1 - usedj[color]]; answer[color][m - 1 - usedj[color]] = k; usedj[color]++; } } } /* for(int i=0;i<n;i++) { for (int j = 0; j < m; j++) cout << answer[i][j] << " "; cout << endl; } cout<<"am in "<<s<<endl; */ allocate_tickets(answer); return s; }
#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...