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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
#include "tickets.h"
#include <vector>
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}
void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
_print(H);
if(sizeof...(T)) cerr<<",";
else cerr<<"\"]";
dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)
int n,m;
vector<vector<int>> s;
ll ans;
struct dt {
int a,b;
pii i,j;
int idx;
};
struct cmp {
bool operator()(const dt &l,const dt &r) {
return (l.a+l.b)>(r.a+r.b);
}
};
long long find_maximum(int k, vector<vector<int>> x) {
n=x.size(); m=x[0].size(); //debug(n,m);
s.resize(n,vector<int>(m,-1));
priority_queue<dt,vector<dt>,cmp> pq;
for(int i=0;i<n;i++) {
for(int j=m-1;j>=m-k;j--) {
ans+=x[i][j];
s[i][j]=m-j-1;
dt temp;
temp.i={i,j}; temp.j={i,k-(m-1-j)-1};
temp.a=x[i][j]; temp.b=x[i][k-(m-1-j)-1];
temp.idx=s[i][j];
pq.push(temp);
}
}
int cntt=(k*n)/2;
while(cntt--) {
dt cur=pq.top(); pq.pop();
ans-=(cur.a+cur.b);
pii I=cur.i,J=cur.j;
s[J.first][J.second]=cur.idx;
s[I.first][I.second]=-1;
}
allocate_tickets(s);
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... |