이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include<iostream>
#include <vector>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define PB push_back
#define F first
#define S second
const int MAXN = 1510;
int n, m;
set<pii> wii[MAXN];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
n = (int)x.size();
m = (int)x[0].size();
ll ret=0;
vector<vector<int>> ans(n, vector<int>(m, -1));
forn(i, n){
vector<pii> tem(m);
forn(j, m) tem[j] = {x[i][j], j};
set<pii> tmp(tem.begin(), tem.end());
swap(wii[i], tmp);
}
forn(tur, k){
ll sum = 0;
vector<pii> obt(n);
forn(i, n) sum-=wii[i].begin()->F;
forn(i, n) obt[i] = {wii[i].begin()->F + wii[i].rbegin()->F, i};
sort(obt.begin(), obt.end(), greater<pii>());
forn(i, (n>>1)){
sum+=obt[i].F;
ans[obt[i].S][wii[obt[i].S].rbegin()->S] = tur;
wii[obt[i].S].erase(prev(wii[obt[i].S].end()));
}
forsn(i, (n>>1), n){
ans[obt[i].S][wii[obt[i].S].begin()->S] = tur;
wii[obt[i].S].erase(wii[obt[i].S].begin());
}
ret+=sum;
}
allocate_tickets(ans);
return ret;
}
# | 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... |