Submission #1082159

#TimeUsernameProblemLanguageResultExecution timeMemory
1082159woodCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms348 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define ll long long #define pb push_back long long find_maximum(int k, std::vector<std::vector<int>> x) { int n = x.size(), m = x[0].size(); vector<vi> ans; for(int i = 0; i<m; i++) ans.pb({x[i][0]}); int l = 0, r = 2e9; while (r-l>1){ int mid = (r+l)/2; ll dif = 0; for(int i = 0; i<n; i++) dif+=mid-ans[i][0]; if(dif<0) l = mid; else r=mid; } int ldif = 0, rdif = 0; for(int i = 0; i<n; i++) ldif+=abs(l-ans[i][0]); for(int i = 0; i<n; i++) rdif+=abs(r-ans[i][0]); return min(ldif,rdif); }
#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...