This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "tickets.h"
#include <vector>
#include <algorithm>
using namespace std;
// <|°_°|>
// M. Broccoli
const int MAX_COLORS = (1500);
pair <int, int> Optimal[MAX_COLORS * MAX_COLORS];
int NbSmall[MAX_COLORS];
long long find_maximum(int nbRounds, vector <vector <int>> Tickets) {
int nbColors = Tickets.size();
int nbTickets = Tickets[0].size();
long long answer = 0;
for (int i = 0; i < nbColors; i ++)
{
for (int j = 0; j < nbRounds; j ++)
{
Optimal[nbRounds * i + j] = {Tickets[i][j] + Tickets[i][j + nbTickets - nbRounds], i};
answer += Tickets[i][j + nbTickets - nbRounds];
}
}
sort(Optimal, Optimal + nbColors * nbRounds);
for (int i = 0; i < (nbColors * nbRounds) / 2; i ++)
{
NbSmall[Optimal[i].second] ++;
answer -= Optimal[i].first;
}
int cnt = nbRounds;
vector <int> row(nbTickets, -1);
vector <vector <int>> Answer(nbColors, row);
for (int i = 0; i < nbColors; i ++)
{
for (int j = 0; j < NbSmall[i]; j ++)
{
Answer[i][j] = -- cnt;
if (!cnt)
cnt = nbRounds;
}
for (int j = 1; j <= nbRounds - NbSmall[i]; j ++)
{
Answer[i][nbTickets - j] = cnt - j < 0 ? cnt - j + nbRounds : cnt - j;
}
}
allocate_tickets(Answer);
return answer;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |