이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll find_maximum(int K, vector<vector<int>> v){
int n = v.size(), m = v[0].size();
vector<vector<int>> pos(n, vector<int>(m, -1));
ll ans = 0;
vector<int> cnt(n), o(n);
for(int i = 0; i < n; i++){
o[i] = i;
cnt[i] = count(v[i].begin(), v[i].end(), 1);
}
vector<int> L(n, 0), R(n, m-1);
for(int k = 0; k < K; k++){
sort(o.begin(), o.end(), [&cnt](int a, int b){
return cnt[a] < cnt[b];
});
for(int j = 0, i = o[0]; j < n/2; j++, i = o[j]){
pos[i][L[i]] = k;
if(v[i][L[i]]) cnt[i]--;
ans-=v[i][L[i]];
L[i]++;
}
for(int j = n/2, i = o[n/2]; j < n; j++, i = o[j]){
pos[i][R[i]] = k;
if(v[i][R[i]]) cnt[i]--;
ans+=v[i][R[i]];
R[i]--;
}
}
allocate_tickets(pos);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |