이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int cnt[1501];
bool cmp(int a, int b){
return cnt[a] < cnt[b];
}
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
ll cursum = 0;
set <pll> st;
ll curl[n], curr[n];
for(int i = 0; i < n; i++){
curr[i] = m - k;
curl[i] = 0;
st.insert({x[i][m - k] + x[i][0], i});
}
// ll cursum = 0;
for(int i = 0; i < n; i++){
for(int j = m - k; j < m; j++)cursum += x[i][j];
}
int raod = n * k / 2;
while(raod--){
pll now = *st.begin();
st.erase(st.begin());
cursum -= now.f;
int ind = now.s;
curl[ind]++;
curr[ind]++;
int ind1 = curl[ind], ind2 = curr[ind];
if(ind2 < m)
st.insert({x[ind][ind1] + x[ind][ind2], ind});
}
//cout << 1;
vector <vector<int> > al;
al.resize(n);
for(int i = 0; i < n; i++){
al[i].resize(m);
for(int j = 0; j < m; j++) al[i][j] = -1;
}
for(int i = 0; i < k; i++){
cnt[i] = 0;
}
for(int i = 0; i < n; i++){
//cout << 1;
int used[k];
fill(used, used + k, 0);
vector <int> vec;
for(int j = 0; j < k; j++){
if(cnt[j] < n / 2) vec.pb(j);
}
//cout << 1;
// cout << curl[i] << ' ';
sort(vec.begin(), vec.end(), cmp);
for(int j = 0; j < curl[i]; j++){
al[i][j] = vec[j];
used[vec[j]] = 1;
cnt[vec[j]]++;
}
//cout << 0;
vector <int> good;
for(int j = 0; j < k; j++){
if(!used[j]) good.pb(j);
}
// cout << 1;
int ind = 0;
for(int j = curr[i]; j < m; j++){
al[i][j] = good[ind++];
}
}
allocate_tickets(al);
return cursum;
}
# | 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... |