이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 2005;
vector<int> cntm(maxn, 0);
bool cmp(const int &i, const int &j) { return cntm[i] < cntm[j]; }
long long find_maximum(int k, vector<vector<int>> x)
{
int n = x.size();
int m = x[0].size();
ll ans = 0;
vector<int> l(n, -1), r(n, m); // kolko minusov mame v tomto riadku
vector<pair<int, int> > p1; // vymenime nejake velke cislo za male cislo
for (int i = 0; i < n; i++) // zoberieme len maxima
{
l[i] = -1, r[i] = m - k;
for (int j = 0; j < k; j++)
p1.push_back({x[i][j]+x[i][r[i]+j], i}), ans += x[i][r[i]+j];
}
sort(p1.begin(), p1.end());
for (int i = 0; i < (n * k)/2; i++)
l[p1[i].second]++, r[p1[i].second]++, ans -= p1[i].first;
vector<int> v(k);
vector<vector<int> > s(n, vector<int>(m, -1));
for (int i = 0; i < k; i++) v[i] = i;
for (int i = 0; i < n; i++)
{
int cnt = 0;
sort(v.begin(), v.end(), cmp);
for (int j = 0; j <= l[i]; j++)
cntm[v[j]]++, s[i][j] = v[cnt++];
for (int j = r[i]; j < m; j++)
s[i][j] = v[cnt++];
}
allocate_tickets(s);
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... |