Submission #947036

#TimeUsernameProblemLanguageResultExecution timeMemory
947036AkibAzmainCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms432 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long find_maximum(int k, std::vector<std::vector<int>> arr) { ll n = arr.size(); ll m = arr[0].size(); std::vector<std::vector<int>> ans (n, vector < int > (m, -1)); ll sum = 0; if (m == 1) { vector < pair < ll, ll > > mn (n), mx (n); for (int i = 0; i < n; ++i) { mn[i] = { arr[i][0], i }; mx[i] = { arr[i][m - 1], i }; } sort (mn.begin (), mn.end ()); sort (mx.begin (), mx.end ()); reverse (mx.begin (), mx.end ()); int i = 0, j = 0; for (int k = 0; k < n / 2; ++k) { if (mn[i].second != mx[j].second) { ans[mn[i].second][0] = 1; ans[mx[j].second][m - 1] = 1; sum += mx[j].first - mn[i].first; ++i, ++j; } else if (mx[j + 1].first - mn[i].first > mx[j].first - mn[i + 1].first) { ans[mn[i].second][0] = 1; ans[mx[j + 1].second][m - 1] = 1; sum += mx[j + 1].first - mn[i].first; ++i, ++++j; } else { ans[mn[i + 1].second][0] = 1; ans[mx[j].second][m - 1] = 1; sum += mx[j].first - mn[i + 1].first; ++++i, ++j; } } } allocate_tickets(ans); 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...