Submission #1043111

#TimeUsernameProblemLanguageResultExecution timeMemory
1043111MarwenElarbiCarnival Tickets (IOI20_tickets)C++17
11 / 100
287 ms69140 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; #define pb push_back #define se second #define fi first long long find_maximum(int k, std::vector<std::vector<int>> x) { long long n = x.size(); long long m = x[0].size(); vector<vector<long long>> y(n,vector<long long> (m)); vector<vector<int>> ans(n,vector<int> (m,-1)); priority_queue<pair<long long,int>> pq; long long res=0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { y[i][j]=x[i][j]; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { res-=y[i][j]; } } int l[n]; int r[n]; for (int i = 0; i < n; ++i) { l[i]=k-1; r[i]=m-1; pq.push({y[i][l[i]]+y[i][r[i]],i}); } for (int i = 0; i < 1ll*k*n/2; ++i) { auto cur=pq.top(); res+=cur.fi; pq.pop(); l[cur.se]--; r[cur.se]--; pq.push({1ll*(y[cur.se][l[cur.se]]+y[cur.se][r[cur.se]]),cur.se}); } for (int i = 0; i < n; ++i) { int cnt=0; for (int j = 0; j <= l[i]; ++j) { ans[i][j]=cnt++; } for (int j = r[i]+1; j < m; ++j) { ans[i][j]=cnt++; } } allocate_tickets(ans); return res; }
#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...