Submission #300782

#TimeUsernameProblemLanguageResultExecution timeMemory
300782haojiandanCarnival Tickets (IOI20_tickets)C++14
100 / 100
1238 ms63280 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; priority_queue<pair<ll,int> > q; ll sum; int pos[1510],tot,st[1510][1510],R[1510],L[1510]; pair<int,int> d[1510]; int vis[1510]; ll find_maximum(int k, vector<vector<int> > x) { int n = x.size(); int m = x[0].size(); vector<vector<int> > ans; for (int i = 0; i < n; i++) { vector<int> row(m); for (int j = 0; j < m; j++) row[j]=-1; ans.push_back(row); } for (int i=0;i<n;i++) { for (int j=0;j<k;j++) st[i][j]=-1; q.push(make_pair(x[i][k-1]+x[i][m-1],i)); pos[i]=1; } for (int I=1;I<=n*k/2;I++) { int i=q.top().second; q.pop(); st[i][k-pos[i]]++,st[i][m-pos[i]]++; pos[i]++; if (k-pos[i]>=0) { q.push(make_pair(x[i][k-pos[i]]+x[i][m-pos[i]],i)); } } for (int i=0;i<n;i++) R[i]=pos[i],vis[i]=-1; tot=-1; while (k--) { for (int i=0;i<n;i++) d[i]=make_pair(R[i],i); sort(d,d+n); reverse(d,d+n); tot++; for (int i=0;i<n/2;i++) vis[d[i].second]=tot; for (int i=0;i<n;i++) if (vis[i]==tot) { ans[i][m-R[i]+1]=tot; R[i]--; } else { ans[i][L[i]]=tot; L[i]++; } } allocate_tickets(ans); for (int i=0;i<n;i++) for (int j=0;j<m;j++) sum+=st[i][j]*x[i][j]; 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...