Submission #587913

#TimeUsernameProblemLanguageResultExecution timeMemory
587913Valaki2Carnival Tickets (IOI20_tickets)C++14
27 / 100
520 ms107892 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define k K #define x X #define int long long #define pb push_back #define mp make_pair #define fi first #define se second int n, m, k; int ans_val; vector<vector<int> > x; vector<vector<int> > ans; bool cmp(const int &a, const int &b) { return x[a][0] + x[a][m - 1] < x[b][0] + x[b][m - 1]; } void solve() { vector<int> v(n, 0); for(int i = 0; i < n; i++) { v[i] = i; } sort(v.begin(), v.end(), cmp); for(int i = 0; i < n / 2; i++) { ans[v[i]][0] = 0; ans_val -= x[v[i]][0]; } for(int i = n / 2; i < n; i++) { ans[v[i]][m - 1] = 0; ans_val += x[v[i]][m - 1]; } } #undef k #undef x int find_maximum(signed k, vector<vector<signed> > x) { n = (int) x.size(); m = (int) x[0].size(); K = k; X.assign(n, vector<int> (m, -2)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { X[i][j] = x[i][j]; } } #define k K #define x X ans.assign(n, vector<int> (m, -1)); solve(); vector<vector<signed> > real_ans(n, vector<signed> (m, -2)); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { real_ans[i][j] = ans[i][j]; } } allocate_tickets(real_ans); return ans_val; }
#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...