#include "bits/stdc++.h"
#include "tickets.h"
using namespace std;
int n ,m ,k;
vector <vector <int>> x;
pair <int64_t ,vector <vector <int>>> construct(vector <int> pref){
//assert(pref.size() == n && accumulate(pref.begin() ,pref.end() ,0) == n*k/2);
// vector <array <int ,3>> fh ,sh;
// for(int i = 0; i < n; i++){
// for(int j = 0; j < pref[i]; j++)
// fh.push_back({x[i][j] ,i ,j});
// for(int j = m-1; j >= m - (k-pref[i]); j--)
// sh.push_back({x[i][j] ,i ,j});
// }
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));
vector<bitset<1501>> taken(n);
for(auto&bs : taken) bs.set();
int round_number = 0;
for(auto&c : fh){
tot -= c[0];
answer[c[1]][c[2]] = round_number;
taken[c[1]][round_number] = false;
round_number = (round_number+1)%k;
}
vector <int> pos(n ,-1);
for(auto&c : sh){
tot += c[0];
pos[c[1]] = taken[c[1]]._Find_next(pos[c[1]]);
answer[c[1]][c[2]] = pos[c[1]];
}
return {tot ,answer};
}
long long find_maximum(int _k, vector<vector<int>> _x) {
x = _x;
n = x.size();
m = x[0].size();
k = _k;
auto ans = construct({});
allocate_tickets(ans.second);
return ans.first;
}
# |
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 |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
There is multiple tickets of color 0 on day 0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Ticket 0 of color 3 is played on invalid day 3 |
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 |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
4 ms |
628 KB |
Output is correct |
5 |
Correct |
44 ms |
5136 KB |
Output is correct |
6 |
Correct |
7 ms |
976 KB |
Output is correct |
7 |
Correct |
9 ms |
1552 KB |
Output is correct |
8 |
Correct |
1302 ms |
99180 KB |
Output is correct |
9 |
Correct |
1126 ms |
92532 KB |
Output is correct |
10 |
Correct |
1129 ms |
92648 KB |
Output is correct |
11 |
Correct |
1243 ms |
99192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
4 ms |
564 KB |
Ticket 0 of color 43 is played on invalid day 25 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
4 ms |
564 KB |
Ticket 0 of color 43 is played on invalid day 25 |
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 |
972 KB |
Output is correct |
7 |
Incorrect |
1 ms |
204 KB |
There is multiple tickets of color 0 on day 0 |
8 |
Halted |
0 ms |
0 KB |
- |