Submission #1119927

#TimeUsernameProblemLanguageResultExecution timeMemory
1119927dsyzCarnival Tickets (IOI20_tickets)C++17
11 / 100
9 ms848 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; using ll = long long; #define MAXN (1000005) long long find_maximum(int k, vector<vector<int>> x) { ll N = x.size(); ll M = x[0].size(); vector<ll> val; for(ll i = 0;i < N;i++){ val.push_back(x[i][0]); val.push_back(x[i][M - 1]); } sort(val.begin(),val.end()); pair<ll,ll> mini = {1e18,-1}; for(auto b : val){ ll sum = 0; for(ll i = 0;i < N;i++){ sum += max(abs(b - x[i][0]),abs(b - x[i][M - 1])); } mini = min(mini,{sum,b}); } vector<vector<int> > ans; for(ll i = 0;i < N;i++){ vector<int> row; for(ll j = 0;j < M;j++){ row.push_back(-1); } ans.push_back(row); } for(ll i = 0;i < N;i++){ if(abs(mini.second - x[i][0]) >= abs(mini.second - x[i][M - 1])){ ans[i][0] = 0; }else{ ans[i][M - 1] = 0; } } allocate_tickets(ans); return mini.first; }
#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...