이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<pair<ll,int> > q;
ll sum;
int pos[1510],tot,st[1510][1510],R[1510],L[1510];
pair<int,int> d[1510];
int vis[1510];
ll find_maximum(int k, vector<vector<int> > x) {
int n = x.size();
int m = x[0].size();
vector<vector<int> > ans;
for (int i = 0; i < n; i++) {
vector<int> row(m);
for (int j = 0; j < m; j++) row[j]=-1;
ans.push_back(row);
}
for (int i=0;i<n;i++) {
for (int j=0;j<k;j++) st[i][j]=-1;
q.push(make_pair(x[i][k-1]+x[i][m-1],i));
pos[i]=1;
}
for (int I=1;I<=n*k/2;I++) {
int i=q.top().second; q.pop();
st[i][k-pos[i]]++,st[i][m-pos[i]]++;
pos[i]++;
if (k-pos[i]>=0) {
q.push(make_pair(x[i][k-pos[i]]+x[i][m-pos[i]],i));
}
}
for (int i=0;i<n;i++) R[i]=pos[i],vis[i]=-1;
tot=-1;
while (k--) {
for (int i=0;i<n;i++) d[i]=make_pair(R[i],i);
sort(d,d+n); reverse(d,d+n);
tot++;
for (int i=0;i<n/2;i++) vis[d[i].second]=tot;
for (int i=0;i<n;i++)
if (vis[i]==tot) {
ans[i][m-R[i]+1]=tot;
R[i]--;
} else {
ans[i][L[i]]=tot;
L[i]++;
}
}
allocate_tickets(ans);
for (int i=0;i<n;i++) for (int j=0;j<m;j++) sum+=st[i][j]*x[i][j];
return sum;
}
# | 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... |