Submission #220692

#TimeUsernameProblemLanguageResultExecution timeMemory
220692VEGAnnTeams (IOI15_teams)C++14
34 / 100
4077 ms31544 KiB
#include <bits/stdc++.h>
#include "teams.h"
#define pii pair<int,int>
#define ft first
#define sd second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
const int oo = 2e9;
set<pii> st;
set<pii>::iterator ite;
vector<pii> vc;
int n;

void init(int N, int A[], int B[]) {
    n = N;

    vc.clear();

    for (int i = 0; i < n; i++)
        vc.PB(MP(A[i], B[i]));

    sort(all(vc));
}

int can(int M, int K[]) {

    sort(K, K + M);
    st.clear();

    int it = 0;

    for (int i = 0; i < M; i++){

        while (it < n && vc[it].ft <= K[i]){
            st.insert(MP(vc[it].sd, it));
            it++;
        }

        for (int j = 0; j < K[i]; j++){
            ite = st.lower_bound(MP(K[i], -oo));

            if (ite == st.end())
                return 0;

            st.erase(ite);
        }
    }

	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...