#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 15e2;
vector<pair<int,int>> nr;
vector <int> bad;
int r[N];
int l[N];
bool vis[N];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer;
answer.resize(n);
ll score = 0;
for(int i = 0;i < n;i++){
answer[i].resize(m);
for(int j = 0;j < k;j++){
nr.push_back({- x[i][j] - x[i][m - k + j], i});
score-=x[i][j];
}
for(int j = 0;j < m;j++){
answer[i][j] = -1;
}
l[i] = k;
}
sort(nr.begin(),nr.end());
for(int i = 0;i < n*k/2;i++){
score+=x[nr[i].second][k - 1 - r[nr[i].second]];
score+=x[nr[i].second][m - 1 - r[nr[i].second]];
r[nr[i].second]++;
l[nr[i].second]--;
}
for(int i = 0;i < n;i++){
cout<<l[i]<<' '<<r[i]<<'\n';
}
for(int i = 0;i < k;i++){
int cnt1 = 0,cnt2 = 0;
for(int j = 0;j < n;j++){
vis[j] = 1;
if(r[j] == 0){
///take left
answer[j][l[j] - 1] = i;
cnt2++;
l[j]--;
}else if(l[j] == 0){
///take right
answer[j][m - r[j]] = i;
cnt1++;
r[j]--;
}else vis[j] = 0;
}
for(int j = 0;j < n;j++){
if(!vis[j]){
vis[j] = 1;
if(cnt1 != n/2){
///take right
answer[j][m - r[j]] = i;
cnt1++;
r[j]--;
}else{
///take left
answer[j][l[j] - 1] = i;
cnt2++;
l[j]--;
}
}
}
}
allocate_tickets(answer);
return score;
}
/**
1, [[5, 9], [1, 4], [3, 6], [2, 7]]
4 2 1
5 9
1 4
3 6
2 7
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
secret mismatch |
2 |
Halted |
0 ms |
0 KB |
- |