Submission #421272

#TimeUsernameProblemLanguageResultExecution timeMemory
421272JUANDI321Carnival Tickets (IOI20_tickets)C++17
Compilation error
0 ms0 KiB
#include "tickets.h" #include <vector> #include <iostream> #include <algorithm> using namespace std; 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); } vector<long long> l; long long sum = 0; for (int i = 0; i < n; i++) { l.push_back(x[i][0]); sum+=x[i][0]; for (int j = 0; j < m; j++) answer[i][j] = 0; } long long avg = sum/n, ans1 = 0, ans2 = 0, ans3 = 0; for(int i = 0; i<n; i++)ans1 += max(l[i]-avg, avg-l[i]); avg++; ans = max(ans, ans1); for(int i = 0; i<n; i++)ans2 += max(l[i]-avg, avg-l[i]); avg-; avg--; ans = max(ans, ans2); for(int i = 0; i<n; i++)ans3 += max(l[i]-avg, avg-l[i]); ans = max(ans, ans3); allocate_tickets(answer); return ans; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:35:2: error: 'ans' was not declared in this scope; did you mean 'ans3'?
   35 |  ans = max(ans, ans1);
      |  ^~~
      |  ans3
tickets.cpp:37:6: error: expected primary-expression before ';' token
   37 |  avg-;
      |      ^