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<bits/stdc++.h>
#include "tickets.h"
using namespace std;
#define ll long long
//#define int ll
#define rep(n) rep1(i,n)
#define rep1(i,n) rep2(i,0,n)
#define rep2(i,a,b) for(int i=a; i<(b); ++i)
#define rep3(i,a,b) for(int i=a; i>=(b); --i)
#define pb push_back
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define inf 0x3f3f3f3f3f3f3f3f
#define pow2(x) (1ll<<(x))
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << " " << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T x){cerr << x << endl;}
template<typename T, typename ...S> void _do(T x, S... y){cerr << x << ", ";_do(y...);}
#else
#define bug(...) 49
#endif
const int maxn=1505;
ll find_maximum(int k, vector<vector<int>> a) {
int n = sz(a);
int m = sz(a[0]);
vector<vector<int>> res;
res.resize(n);
rep(n) res[i].resize(m);
rep(n) rep1(j,m) res[i][j]=-1;
ll ans=0;
int l[maxn],r[maxn];
rep(n) l[i]=0,r[i]=m-1;
pair<ll,int> b[maxn];
rep1(j,k){
rep(n) b[i].first=a[i][l[i]]+a[i][r[i]],b[i].second=i;
sort(b,b+n);
rep(n/2){
ans-=a[b[i].second][l[b[i].second]];
res[b[i].second][l[b[i].second]]=j;
l[b[i].second]++;
}
rep(n/2){
ans+=a[b[n/2+i].second][r[b[n/2+i].second]];
res[b[n/2+i].second][r[b[n/2+i].second]]=j;
r[b[n/2+i].second]--;
}
}
allocate_tickets(res);
return ans;
}
# | 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... |