#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
#define all(x) x.begin(),x.end()
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(n, vector<int>(m, -1));
vector<array<int, 3>> a;
for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) a.pb({x[i][j], i, j});
sort(all(a));
vector<vector<vector<int>>> C(n, vector<vector<int>>(2));
// ll val = 0;
for(int i = 0; i < n*m; ++i){
if(i < n*m/2){
// val -= a[i][0];
C[a[i][1]][0].pb(a[i][2]);
}else{
// val += a[i][0];
C[a[i][1]][1].pb(a[i][2]);
}
}
// cout << "f" << endl;
ll val = 0;
for(int i = 0; i < k; ++i){
set<pair<int, int>> S;
for(int i = 0; i < n; ++i){
S.insert({C[i][1].size(), i});
}
int cur =0 ;
auto it = S.begin();
vector<ll> tot;
while(it != S.end()){
int v = (*it).second;
if((cur < n/2 && C[v][0].size()) || (cur >= n/2 && C[v][1].size() == 0)){
tot.pb(x[v][C[v][0].back()]);
answer[v][C[v][0].back()] = i;
C[v][0].pop_back();
}else{
tot.pb(x[v][C[v][1].back()]);
answer[v][C[v][1].back()] = i;
C[v][1].pop_back();
}
++cur;
it = next(it);
}
sort(all(tot));
for(int j = 0; j < n/2; ++j){
val += tot[j + n/2] - tot[j];
}
// cout << "f" << endl;
}
// for (int i = 0; i < n; i++) {
// std::vector<int> row(m);
// for (int j = 0; j < m; j++) {
// if (j < k) {
// row[j] = j;
// } else {
// row[j] = -1;
// }
// }
// answer.push_back(row);
// }
allocate_tickets(answer);
return val;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Contestant returned 803235448 while correct return value is 860858182. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Contestant returned 4 while correct return value is 6. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
604 KB |
Output is correct |
5 |
Correct |
25 ms |
3832 KB |
Output is correct |
6 |
Correct |
4 ms |
936 KB |
Output is correct |
7 |
Correct |
5 ms |
1312 KB |
Output is correct |
8 |
Correct |
751 ms |
85000 KB |
Output is correct |
9 |
Correct |
766 ms |
80040 KB |
Output is correct |
10 |
Correct |
693 ms |
78820 KB |
Output is correct |
11 |
Correct |
786 ms |
85072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Contestant returned 19953261489 while correct return value is 39376297182. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
604 KB |
Contestant returned 19953261489 while correct return value is 39376297182. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Contestant returned 803235448 while correct return value is 860858182. |
8 |
Halted |
0 ms |
0 KB |
- |