Submission #448177

#TimeUsernameProblemLanguageResultExecution timeMemory
448177dxz05Carnival Tickets (IOI20_tickets)C++14
27 / 100
627 ms73184 KiB
#include "tickets.h" #include <bits/stdc++.h> typedef long long ll; #define MP make_pair using namespace std; long long find_maximum(int k, vector<vector<int>> a) { int n = a.size(); int m = a[0].size(); if (m == 1) { vector<vector<int>> answer(n, vector<int>(m, 0)); allocate_tickets(answer); vector<int> v; for (int i = 0; i < n; i++) v.push_back(a[i][0]); sort(v.begin(), v.end()); ll ans = 0; for (int i = 0; i < n; i++){ if (i < n / 2) ans -= v[i]; else ans += v[i]; } return ans; } ll ans = 0; vector<vector<int>> answer(n, vector<int>(m, -1)); vector<pair<pair<ll, int>, pair<int, int>>> v; for (int i = 0; i < n; i++){ int l = min_element(a[i].begin(), a[i].end()) - a[i].begin(); int r = max_element(a[i].begin(), a[i].end()) - a[i].begin(); answer[i][r] = 0; ans += a[i][r]; v.emplace_back(MP(-a[i][r] - a[i][l], i), MP(l, r)); } sort(v.rbegin(), v.rend()); for (int i = 0; i < n / 2; i++){ ans += v[i].first.first; answer[v[i].first.second][v[i].second.first] = 0; answer[v[i].first.second][v[i].second.second] = -1; } allocate_tickets(answer); return ans; }
#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...