이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
#define pb push_back
#define se second
#define fi first
long long find_maximum(int k, std::vector<std::vector<int>> x) {
long long n = x.size();
int m = x[0].size();
vector<vector<int>> ans(n,vector<int> (m,-1));
priority_queue<pair<pair<int,int>,pair<int,int>>> mx;
long long res=0;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < k; ++j)
{
ans[i][j]=2;
}
}
for (int i = 0; i < n; ++i)
{
for (int j = m-k; j < m; ++j)
{
mx.push({{x[i][j],ans[i][j]},{i,j}});
}
}
for (int i = 0; i < k*n/2; ++i)
{
auto cur=mx.top();
res+=cur.fi.fi;
mx.pop();
ans[cur.se.fi][cur.se.se]=1;
}
priority_queue<pair<pair<int,int>,pair<int,int>>,vector<pair<pair<int,int>,pair<int,int>>>,greater<pair<pair<int,int>,pair<int,int>>>> mn;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < k; ++j)
{
mn.push({{x[i][j],ans[i][j]},{i,j}});
}
}
for (int i = 0; i < k*n/2; ++i)
{
auto cur=mn.top();
res-=cur.fi.fi;
mn.pop();
ans[cur.se.fi][cur.se.se]=0;
}
int lst[n];
memset(lst,0,sizeof lst);
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if(ans[i][j]==2) ans[i][j]=-1;
}
}
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if(ans[i][j]==-1) continue;
ans[i][j]=lst[i]++;
}
}
allocate_tickets(ans);
return res;
}
# | 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... |