#include "tickets.h"
#include <bits/stdc++.h>
#define va first
#define vb second
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
const int MN = 1505;
const int MOD = 1e9+7;
const int INF = 1e9;
vector<pii> T;
int a[MN],s[MN],cur[MN],D[MN],U[MN];
int n,m;
int cal(int x)
{
return D[x]+1+m-U[x];
}
bool cmp(int x, int y)
{
return D[x]<D[y];
}
ll find_maximum(int k, vector<vector<int>> x) {
n = x.size();
m = x[0].size();
ll sum = 0;
vector<vector<int>> ans;
vector<int> row(m,-1);
for(int i=0; i<n; i++){
ans.push_back(row);
}
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
T.emplace_back(x[i][j],i);
sort(all(T));
int s=0, e=n*m-1;
for(int i=0; i<n; i++){
D[i] = -1;
U[i] = m;
}
while(s<n*k/2){
if(cal(T[s].vb)==k) continue;
D[T[s].vb]++;
s++;
}
while(e>=n*m-n*k/2){
if(cal(T[e].vb)==k) continue;
U[T[e].vb]--;
e--;
}
vector<int> v(n);
for(int i=0; i<k; i++){
for(int j=0; j<n; j++) v[j] = j;
sort(all(v),cmp);
for(int j=0; j<n; j++){
if(j>=n/2){
int c = v[j];
ans[c][D[c]] = i;
sum -= x[c][D[c]];
D[c]--;
}
else{
int c = v[j];
ans[c][U[c]] = i;
sum += x[c][U[c]];
U[c]++;
}
}
}
allocate_tickets(ans);
return sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
3077 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3072 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
512 KB |
Output is correct |
5 |
Correct |
57 ms |
3180 KB |
Output is correct |
6 |
Correct |
9 ms |
768 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
1135 ms |
71976 KB |
Output is correct |
9 |
Correct |
1055 ms |
67024 KB |
Output is correct |
10 |
Correct |
1164 ms |
67160 KB |
Output is correct |
11 |
Correct |
1164 ms |
71872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
512 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
3064 ms |
512 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Execution timed out |
3077 ms |
256 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |