Submission #982072

#TimeUsernameProblemLanguageResultExecution timeMemory
982072steveonalexRobots (IOI13_robots)C++17
100 / 100
1324 ms24852 KiB
#include <bits/stdc++.h>
#include "robots.h"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define ALL(v) (v).begin(), (v).end()
#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)

// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng(1);
ll rngesus(ll l, ll r){return ((ull) rng()) % (r - l + 1) + l;}

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll LASTBIT(ll mask){return mask & (-mask);}
ll pop_cnt(ll mask){return __builtin_popcountll(mask);}
ll ctz(ll mask){return __builtin_ctzll(mask);}
ll clz(ll mask){return __builtin_clzll(mask);}
ll logOf(ll mask){return 63 - clz(mask);}

template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b){a = b; return true;}
        return false;
    }
template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b){a = b; return true;}
        return false;
    }
template <class T>
    void printArr(T a, string separator = " ", string finish = "\n", ostream& out = cout){
        for(auto i: a) out << i << separator;
        out << finish;
    }
template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }
int putaway(int A,int B,int T,
int X[],int Y[],int W[],int S[]){
    int l = 1, r = T + 1;
    vector<pair<int, int>> stuff(T);
    for(int i = 0; i<T; ++i) stuff[i] = {W[i], S[i]};
    sort(ALL(stuff));
    
    vector<int> weak(A), small(B);
    for(int i = 0; i<A; ++i) weak[i] = X[i];
    for(int i = 0; i<B; ++i) small[i] = Y[i];

    sort(ALL(weak));
    sort(ALL(small));

    reverse(ALL(small));

    while(l < r){
        int mid = (l + r) >> 1;
        priority_queue<int> pq;
        int j = 0;
        for(int i: weak){
            while(j < T && stuff[j].first < i) 
                pq.push(stuff[j++].second);

            for(int j = 0; j < mid; ++j){
                if (pq.empty()) break;
                pq.pop();
            }
        }

        while(j < T){
            pq.push(stuff[j++].second);
        }

        for(int i: small){
            for(int j = 0; j< mid; ++j){
                if (pq.empty()) break;
                if (i > pq.top()){
                    pq.pop();
                }
                else break;
            }
        }

        if (pq.empty()) r = mid;
        else l = mid + 1;
    }

    if (l == T + 1) return -1;
    return l;
}


// int main(void){
//     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     int a, b, t; cin >> a >> b >> t;
//     int X[a], Y[b], W[t], S[t];
//     for(int i  =0; i<a; ++i) cin >> X[i];
//     for(int i = 0; i<b; ++i) cin >> Y[i];
//     for(int i = 0; i<t; ++i) cin >> W[i];
//     for(int i = 0; i<t; ++i) cin >> S[i];

//     cout << putaway(a, b, t, X, Y, W, S) << "\n";

//     return 0;
// }
#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...