Submission #779402

#TimeUsernameProblemLanguageResultExecution timeMemory
779402JosiaCarnival Tickets (IOI20_tickets)C++17
11 / 100
2 ms696 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define int long long int find_maximum(signed k, std::vector<std::vector<signed>> x) { int colors = x.size(); int ticketsPerColor = x[0].size(); int rounds = k; if (ticketsPerColor == 1) { int m = ticketsPerColor; int n = colors; int res = 0; assert(m == 1); vector<int> vals; for (int i = 0; i<n; i++) { vals.push_back(x[i][0]); } sort(vals.begin(), vals.end()); int med = vals[n/2]; for (int i: vals) res += abs(i-med); vector<vector<signed>> cards(n, vector<signed>(m)); for (int i=0; i<n; i++) { cards[i][0] = 0; } allocate_tickets(cards); return res; } vector<array<int, 4>> cards(colors); for (int i=0; i<colors; i++) { cards[i][0] = (*max_element(x[i].begin(), x[i].end()))-(*min_element(x[i].begin(), x[i].end())); cards[i][1] = min_element(x[i].begin(), x[i].end())-x[i].begin(); cards[i][2] = max_element(x[i].begin(), x[i].end())-x[i].begin(); cards[i][3] = i; } sort(cards.begin(), cards.end()); int res = 0; vector<vector<signed>> allocation(colors, vector<signed>(ticketsPerColor, -1)); for (int i = 0; i<colors/2; i++) { res += x[cards[i][3]][cards[i][2]]; allocation[cards[i][3]][cards[i][2]] = 1; } for (int i = colors/2; i<colors; i++) { res -= x[cards[i][3]][cards[i][1]]; allocation[cards[i][3]][cards[i][1]] = 1; } allocate_tickets(allocation); return res; }

Compilation message (stderr)

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:14:6: warning: unused variable 'rounds' [-Wunused-variable]
   14 |  int rounds = k;
      |      ^~~~~~
#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...