Submission #1032920

#TimeUsernameProblemLanguageResultExecution timeMemory
1032920ZicrusCarnival Tickets (IOI20_tickets)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "tickets.h" using namespace std; typedef long long ll; ll sub1(int k, vector<vector<int>> x) { vector<int> s(x.size()); for (int i = 0; i < x.size(); i++) s[i] = x[i][0]; sort(s.begin(), s.end()); ll median = s[s.size() / 2]; ll sum = 0; for (auto &e : s) sum += abs(e - median); allocate_tickets(vector<vector<int>>(s.size(), vector<int>(1))); return sum; } ll sub2(int k, vector<vector<int>> x) { ll n = x.size(), m = x[0].size(); vector<pair<ll, ll>> avgId(n); for (int i = 0; i < n; i++) { avgId.push_back({x[i].front() + x[i].back(), i}); } sort(avgId.begin(), avgId.end()); vector<ll> choices(n); vector<vector<int>> res(n, vector<int>(m, -1)); for (int i = 0; i < n/2; i++) { choices[i] = x[avgId[i].second].front(); res[avgId[i].second].front() = 0; } for (int i = n/2; i < n; i++) { choices[i] = x[avgId[i].second].back(); res[avgId[i].second].back() = 0; } ll median = choices[n/2]; ll sum = 0; for (auto &e : choices) sum += abs(e - median); allocate_tickets(res); return sum; } ll find_maximum(int k, vector<vector<int>> x) { if (k > 1) return sub1(k, x); return sub2(k, x); }

Compilation message (stderr)

tickets.cpp: In function 'll sub1(int, std::vector<std::vector<int> >)':
tickets.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < x.size(); i++) s[i] = x[i][0];
      |                     ~~^~~~~~~~~~
#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...