이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 1500 + 7;
vector<pair<int, pair<int, int>>> kol;
vector<vector<int>> gam;
vector<int> lft[N][2];
int il[N];
bool Cp(int a, int b)
{
int x = max(lft[a][0].size(), lft[a][1].size());
int y = max(lft[b][0].size(), lft[b][1].size());
return (x > y);
}
void DoAns(int n, int m, int k)
{
vector<int> ord;
for(int i = 0; i < n; ++i)
{
//cerr << "il: " << i << " " << il[i] << "\n";
ord.pb(i);
for(int j = 0; j < k - il[i]; ++j)
lft[i][0].pb(j);
for(int j = m - il[i]; j < m; ++j)
lft[i][1].pb(j);
}
for(int l = 0; l < k; ++l)
{
sort(ord.begin(), ord.end(), Cp);
int ilu = 0, ild = 0;
for(int i = 0; i < n; ++i)
{
int v = ord[i];
//cerr << (int)lft[v][1].size() - (int)lft[v][0].size() << " ";
if(((int)lft[v][0].size() > (int)lft[v][1].size() && ilu < n / 2) || ((int)lft[v][0].size() == (int)lft[v][1].size() && ilu < ild) || (ild == n / 2))
{
/*if(lft[v][0].size() == 0)
{
cerr << "KURWA\n";
}*/
++ilu;
gam[v][lft[v][0].back()] = l;
lft[v][0].pop_back();
}else
{
/*if(lft[v][1].size() == 0)
{
cerr << "KURWA\n";
}*/
++ild;
gam[v][lft[v][1].back()] = l;
lft[v][1].pop_back();
}
}
//cerr << "\n";
}
}
ll find_maximum(int k, vector<vector<int>> x)
{
int n = x.size(), m = x[0].size();
gam = x;
ll answer = 0LL;
for(int i = 0; i < n; ++i)
{
for(int j = 0; j < m; ++j)
gam[i][j] = -1;
for(int j = 0; j < k; ++j)
answer -= (ll)x[i][j];
for(int j = 0; j < k; ++j)
kol.pb(make_pair(x[i][k - j - 1] + x[i][m - j - 1], make_pair(-(j + 1), i)));
}
sort(kol.begin(), kol.end());
reverse(kol.begin(), kol.end());
//cerr << answer << "\n";
for(int i = 0; i < (n * k) / 2; ++i)
{
//cerr << "kol: " << kol[i].st << " " << kol[i].nd.st << " " << kol[i].nd.nd << "\n";
++il[kol[i].nd.nd];
answer += (ll)kol[i].st;
//cerr << i << " " << answer << " " << kol[i].st << "\n";
}
DoAns(n, m, k);
allocate_tickets(gam);
return answer;
}
# | 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... |