# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471260 | Cross_Ratio | 카니발 티켓 (IOI20_tickets) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
//void allocate_tickets(vector<vector<int>>);
typedef pair<int,int> P;
long long find_maximum(int k, vector<vector<int> > x) {
int N = x.size();
int M = x[0].size();
vector<vector<int> > ans;
ans.resize(N);
int i;
for(i=0;i<N;i++) {
ans[i].resize(M);
fill(ans[i].begin(),ans[i].end(),-1);
}
long long int cnt = 0;
vector<int> pt1;
vector<int> pt2;
pt1.resize(N);
pt2.resize(N);
fill(pt2.begin(),pt2.end(),M-1);
int j, st;
for(j=0;j<k;j++) {
vector<P> V;
for(i=0;i<N;i++) {
V.push_back(P(x[i][pt2[i]]+x[i][pt1[i]],i));
}
sort(V.begin(),V.end());
for(i=0;i<N;i++) {
int n = V[i].second;
if(i < N / 2) {
ans[n][pt1[n]] = j;
cnt -= x[n][pt1[n]];
pt1[n]++;
}
else {
ans[n][pt2[n]] = j;
cnt += x[n][pt2[n]];
pt2[n]--;
}
}
}
allocate_tickets(ans);
return cnt;
}