Submission #20197

#TimeUsernameProblemLanguageResultExecution timeMemory
20197magic_fateTeams (IOI15_teams)C++98
0 / 100
4078 ms32 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 500000 + 10;
const int MAX_M = 500000 + 10;

int bk_sz;
int M , K[MAX_M];
int N , A[MAX_N] , B[MAX_N];

void init(int N0 , int A0[] , int B0[]) {
    N = N0;
    for(int i = 0; i < N; i++) {
        A[i] = A0[i];
        B[i] = B0[i];
    }

    bk_sz = (int)sqrt(N);
}

int solve1() {
    priority_queue<int> pq;
    vector<pair<int,int> > v_pii;

    for(int i = 0; i < N; i++) v_pii.push_back(make_pair(A[i] , B[i]));

    sort(v_pii.begin() , v_pii.end());

    for(int i = 0 , j = 0; i < M; i++) {
        while(!pq.empty() && pq.top() < K[i]) pq.pop();
        while(j < N && v_pii[j].first == i) pq.push(v_pii[j++].second);

        int x = K[i];

        while(x && !pq.empty()) {
            pq.pop();
            x--;
        }

        if(x) return 0;
    }

    return 1;
}

int can(int M0 , int K0[]) {
    M = M0;
    for(int i = 0; i < M; i++) K[i] = K0[i];

    sort(K , K + M);

    return solve1();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...