이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
#define DIM 2000
#define INF 2000000000000000000LL
using namespace std;
int n,m;
priority_queue <pair<long long,int> > h;
pair <int,int> poz[DIM];
long long find_maximum (int k, vector<vector<int> > x){
n = x.size(), m = x[0].size();
int i,j;
vector <pair<int,int> > v;
vector <vector<int> > ans;
ans.resize(n);
for (i=0;i<n;i++){
ans[i].resize(m,-1);
poz[i] = make_pair (k-1,m-1);
}
long long sum = 0;
/// le pun de la inceput pe primele k cu minus
for (i=0;i<n;i++)
for (j=0;j<k;j++){
sum -= x[i][j];
ans[i][j] = j;
}
/// vreau sa fac jumatate din minus in plus
for (i=0;i<n;i++)
h.push (make_pair(x[i][poz[i].first] + x[i][poz[i].second],i));
for (i=1;i<=n*k/2;i++){
sum += h.top().first;
int idx = h.top().second;
h.pop();
ans[idx][poz[idx].second] = ans[idx][poz[idx].first];
if (poz[idx].first != poz[idx].second)
ans[idx][poz[idx].first] = -1;
poz[idx].first--, poz[idx].second--;
if (poz[idx].first >= 0)
h.push (make_pair(x[idx][poz[idx].first] + x[idx][poz[idx].second], idx));
}
allocate_tickets(ans);
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... |