Submission #304625

#TimeUsernameProblemLanguageResultExecution timeMemory
304625loliconCarnival Tickets (IOI20_tickets)C++14
0 / 100
1 ms384 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> ans; for (int i = 0; i < n; i++) { vector<int> row(m, -1); ans.push_back(row); } int Cnt = 0; vector<int> cnt(n); vector<pair<int, int>> v; for(int i = 0; i < n; i++) { int l = x[i][0]; int r = x[i][m - 1]; v.emplace_back(l, i); v.emplace_back(r, i); v.emplace_back((l + r) / 2, i); } int p; sort(all(v)); for(int i = 0; i < 3 * n; i++) { cnt[v[i].second]++; if(cnt[v[i].second] == 2) { Cnt++; } if(Cnt == n / 2) { p = i; break; } } for(int i = 0; i < 3 * n; i++) { if(cnt[v[i].second] >= 2) ans[v[i].second][0] = 0; else ans[v[i].second][m - 1] = 0; } // cal long long ret = 0; vector<vector<int>> T(k); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(ans[i][j] != -1) { T[ans[i][j]].push_back(x[i][j]); } } } for(int i = 0; i < k; i++) { sort(begin(T[i]), end(T[i])); int p = T[i][n / 2]; for(int j = 0; j < n; j++) { ret = ret + (long long)abs(p - T[i][j]); } } //allocate_tickets(ans); /*for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cout << ans[i][j] << " \n"[j == m - 1]; } }*/ return ret; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:6: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   26 |  int p;
      |      ^
#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...