This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |