# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
363657 | Sparky_09 | 카니발 티켓 (IOI20_tickets) | C++17 | 0 ms | 0 KiB |
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"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
void usaco(string s){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
int n,m;
const ll N = 2e3+100;
ll t[N];
struct node{
ll num,val;
}a[N];
ll cmp(node a,node b){
return a.val < b.val;
}
long long find_maximum(int k, vector<vector<int>> x) {
n = x.size();
m = x[0].size();
vector<vector<int>> ans(n, vector<int>(m, -1));
if(m == 1){
for(int i = 0; i < n; i++)
ans[i][0]=0;
allocate_tickets(ans);
ll s = 0;
for(int i = 0; i < n; i++)
t[i] = x[i][0];
sort(t, t+n);
for(int i = 0;i < n/2; i++)
s -= t[i];
for(int i = n/2; i < n; i++)
s += t[i];
return s;
}
else(k == 1){
ll s = 0;
for(int i = 0; i < n; i++)
s += x[i][n-1];
for(int i = 0; i < n; i++)
a[i] = (node){i,x[i][0]+x[i][n-1]};
sort(a , a+n, cmp);
for(int i = 0; i < n/2; i++)
s -= a[i].val, ans[a[i].num][0] = 0;
for(int i= n/2 ;i < n; i++)
ans[a[i].num][n-1]=0;
allocate_tickets(ans);
return s;
}
}