이 제출은 이전 버전의 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));
vector<pair<int, int>> sth;
for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) sth.pb({i, j});
sort(sth.begin(), sth.end(), [&](pair<int, int> a, pair<int, int> b){
if(v[a.f][a.sc] == v[b.f][b.sc]) return make_pair(a.sc, a.f) > make_pair(b.sc, b.f);
return v[a.f][a.sc] > v[b.f][b.sc];
});
ll ans = 0;
vector<int> cnt(n), o(n);
vector<vector<bool>> plus(n, vector<bool>(m, 0));
for(int i = 0; i < (n*m)/2; i++) cnt[sth[i].f]++, plus[sth[i].f][sth[i].sc] = 1;
for(int i = 0; i < n; i++) o[i] = i;
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(plus[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(plus[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... |