Submission #581407

#TimeUsernameProblemLanguageResultExecution timeMemory
581407MohamedFaresNebiliCarnival Tickets (IOI20_tickets)C++14
16 / 100
521 ms51328 KiB
#include <bits/stdc++.h>
#include "tickets.h"
#include <ext/pb_ds/assoc_container.hpp>
 
        using namespace std;
        using namespace __gnu_pbds;
 
        using ll = long long;
        using pi = pair<ll, pair<ll, ll>>;
        using ii = pair<int, int>;
 
        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second
 
        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
 
        ll find_maximum(int K, vector<vector<int>> A) {
            int N = A.size(), M = A[0].size(); ll res = 0;
            vector<vector<int>> S(N, vector<int> (M, -1));
            vector<pair<ll, ll>> arr;
 
            for(int l = 0; l < N; l++) {
                res += A[l][M - 1]; S[l][M - 1] = 0;
                arr.pb({A[l][0] + A[l][M - 1], l});
            }
            sort(arr.begin(), arr.end());
 
            for(int l = 0; l < N / 2; l++) {
                res -= arr[l].ff; S[arr[l].ss][0] = 0;
                S[arr[l].ss][M - 1] = -1;
            }
            allocate_tickets(S);
            return res;
        }
#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...