Submission #320024

#TimeUsernameProblemLanguageResultExecution timeMemory
320024wildturtleCarnival Tickets (IOI20_tickets)C++14
100 / 100
963 ms60772 KiB
#include "tickets.h" #include<bits/stdc++.h> using namespace std; int idx,l,l1,A[500005]; long long ans; set < pair < int , int > > st; long long find_maximum(int k, vector< vector < int > > x) { int n=x.size(); int m=x[0].size(); for(int i=0;i<n;i++) { for(int j=m-k;j<m;j++) { ans+=x[i][j]; } st.insert({x[i][m-k]+x[i][0],i}); } for(int i=1;i<=(n*k)/2;i++) { idx=(*st.begin()).second; ans-=(*st.begin()).first; st.erase(*st.begin()); A[idx]++; if(A[idx]<k) st.insert({x[idx][m-k+A[idx]]+x[idx][A[idx]],idx}); } vector < vector < int > > answer; for (int i = 0; i < n; i++) { vector<int> row; for (int j = 0; j < A[i]; j++) { row.push_back(l); l++; l%=k; } for(int j=A[i];j<m-(k-A[i]);j++) { row.push_back(-1); } l1=l; for(int j=m-(k-A[i]);j<m;j++) { row.push_back(l1); l1++; l1%=k; } answer.push_back(row); } allocate_tickets(answer); return ans; } /*int main() { cout<<find_maximum(2, { {0, 2, 5}, {1, 1, 3} } );//2, [[0, 2, 5],[1, 1, 3]] }*/
#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...