Submission #301118

#TimeUsernameProblemLanguageResultExecution timeMemory
301118rocks03Carnival Tickets (IOI20_tickets)C++14
11 / 100
2 ms768 KiB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int) (x).size())
using namespace std;

void allocate_tickets(vector<vector<int>> _d);

int N, M;

long long find_maximum(int k, vector<vector<int>> x){
    N = SZ(x), M = SZ(x[0]);
    vector<vector<int>> alloc = x;
    ll ans = 0;
    if(M == 1){
        vector<int> v(N);
        for(int i = 0; i < N; i++){
            v[i] = x[i][0];
        }
        sort(v.begin(), v.end());
        int median1 = v[(N-1)/2], median2 = v[N/2];
        ll ans1 = 0, ans2 = 0;
        for(int i = 0; i < N; i++){
            ans1 += abs(median1 - v[i]);
            ans2 += abs(median2 - v[i]);
        }
        for(int i = 0; i < N; i++){
            alloc[i][0] = 0;
        }
        ans = max(ans1, ans2);
    }
    allocate_tickets(alloc);
    return ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...