Submission #421242

#TimeUsernameProblemLanguageResultExecution timeMemory
421242MonchitoCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms204 KiB
#include "tickets.h" #include <vector> #include <iostream> #include <algorithm> #include <deque> using namespace std; using ll = long long; using ii = pair<int,int>; using vi = vector<int>; using vvi = vector<vi>; const ll INF = 1e18; int n, m, K; vector<vi> answer; deque<pair<int,ll>> hi, lo; ll find_maximum(int k, vvi x){ n = x.size(); m = x[0].size(); answer = vvi(n, vi(m, -1)); ll S = 0, max_value = -INF, min_value = INF; for(int i=0; i<n; i++){ answer[i][0] = 0; max_value = max((ll)x[i][0], max_value); min_value = min((ll)x[i][0], min_value); } ll mid_floor = (max_value + min_value) / 2; ll mid_ceil = (max_value + min_value + 1) / 2; ll s1, s2; s1 = s2 = 0; for(int i=0; i<n; i++) s1 += abs(x[i][0] - mid_floor); for(int i=0; i<n; i++) s2 += abs(x[i][0] - mid_ceil); allocate_tickets(answer); return min(s1, s2); }

Compilation message (stderr)

tickets.cpp: In function 'll find_maximum(int, vvi)':
tickets.cpp:24:8: warning: unused variable 'S' [-Wunused-variable]
   24 |     ll S = 0, max_value = -INF, min_value = INF;
      |        ^
#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...