제출 #31907

#제출 시각아이디문제언어결과실행 시간메모리
31907top34051Teams (IOI15_teams)C++14
34 / 100
4000 ms6716 KiB
#include "teams.h"
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005

int n;
pair<int,int> p[maxn];
priority_queue<int> heap;

void init(int N, int A[], int B[]) {
    n = N;
    for(int i=0;i<n;i++) p[i] = {A[i], B[i]};
    sort(&p[0],&p[n]);
}

int can(int M, int K[]) {
    int i,j,sz;
    while(!heap.empty()) heap.pop();
    sort(&K[0],&K[M]);
    for(i=0,j=0;i<M;i++) {
        while(j<n && p[j].first<=K[i]) heap.push(-p[j++].second);
        while(!heap.empty() && -heap.top()<K[i]) heap.pop();
        for(sz=0;sz<K[i];sz++) {
            if(heap.empty()) return 0;
            heap.pop();
        }
    }
    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...