#include "bits/stdc++.h"
#include "tickets.h"
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
assert(m == k);
vector <array <int ,3>> all; //{val ,color ,index}
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
all.push_back({x[i][j] ,i ,j});
sort(all.begin() ,all.end());
vector <array <int ,3>> fh{all.begin() ,all.begin() + (int)all.size()/2};
vector <array <int ,3>> sh{all.begin() + (int)all.size()/2 ,all.end()};
sort(fh.begin() ,fh.end() ,[](auto&i ,auto&j){ return i[1] < j[1]; });
sort(sh.begin() ,sh.end() ,[](auto&i ,auto&j){ return i[1] < j[1]; });
int64_t tot = 0;
vector<vector<int>> answer(n ,vector<int>(m ,-1));
set <int> mex[n];
for(int i = 0; i < k; i++)
for(int c = 0; c < n; c++)
mex[c].insert(i);
int round_number = 0;
for(auto&c : fh){
tot -= c[0];
answer[c[1]][c[2]] = round_number;
mex[c[1]].erase(answer[c[1]][c[2]]);
//cout << "(" << c[1] << " ," << c[2] << ") -> " << answer[c[1]][c[2]] << endl;
round_number = (round_number+1)%k;
}
for(auto&c : sh){
tot += c[0];
answer[c[1]][c[2]] = *mex[c[1]].begin();
//cout << "(" << c[1] << " ," << c[2] << ") -> " << answer[c[1]][c[2]] << endl;
mex[c[1]].erase(answer[c[1]][c[2]]);
}
allocate_tickets(answer);
return tot;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
5 ms |
844 KB |
Output is correct |
5 |
Correct |
77 ms |
8552 KB |
Output is correct |
6 |
Correct |
11 ms |
1624 KB |
Output is correct |
7 |
Correct |
13 ms |
1848 KB |
Output is correct |
8 |
Correct |
2021 ms |
207272 KB |
Output is correct |
9 |
Correct |
1777 ms |
193712 KB |
Output is correct |
10 |
Correct |
1778 ms |
193544 KB |
Output is correct |
11 |
Correct |
1983 ms |
207256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
3 ms |
496 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
3 ms |
496 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
7 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |