Submission #559882

#TimeUsernameProblemLanguageResultExecution timeMemory
559882AlperenTCarnival Tickets (IOI20_tickets)C++17
27 / 100
462 ms51344 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; struct Item{ int x, i, j; bool operator < (const Item &sc) const{ return x < sc.x; } }; long long find_maximum(int k, vector<vector<int>> arr){ int n = arr.size(); int m = arr[0].size(); vector ans(n, vector(m, -1)); long long ansvalue = 0; vector<Item> v; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ ansvalue += arr[i][m - 1 - j]; } } for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ v.push_back({arr[i][j] + arr[i][m - k + j], i, j}); } } sort(v.begin(), v.end()); for(int i = 0; i < (n * k) / 2; i++){ ansvalue -= v[i].x; ans[v[i].i][v[i].j] = i / (n / 2); } for(int i = (n * k) / 2; i < n * k; i++){ ans[v[i].i][m - k + v[i].j] = (i - (n * k) / 2) / (n / 2); } allocate_tickets(ans); return ansvalue; }
#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...