Submission #401159

#TimeUsernameProblemLanguageResultExecution timeMemory
401159my99nCarnival Tickets (IOI20_tickets)C++14
11 / 100
2 ms588 KiB
#include "tickets.h" #include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; long long findanswer (vector<int> round) { sort(all(round)); long long med = round[round.size()/2]; long long ans = 0; for (int i = 0; i < round.size(); i++) { ans += abs(med-round[i]); } return ans; } long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row(m); for (int j = 0; j < m; j++) { if (j < k) { row[j] = j; } else { row[j] = -1; } } answer.push_back(row); } allocate_tickets(answer); vector<int> round; for (int i = 0; i < n; i++) { round.push_back(x[i][0]); } return findanswer(round); }

Compilation message (stderr)

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