제출 #333749

#제출 시각아이디문제언어결과실행 시간메모리
333749rqi팀들 (IOI15_teams)C++14
34 / 100
4098 ms16128 KiB
#include "teams.h"
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()

const int mx = 500005;

int N;
int A[mx];
int B[mx];
vpi students;

void init(int _N, int _A[], int _B[]) {
	N = _N;
	for(int i = 0; i < N; i++){
		A[i] = _A[i]; B[i] = _B[i];
	}

	for(int i = 0; i < N; i++){
		students.pb(mp(A[i], B[i]));
	}
	sort(all(students));
}

int can(int M, int _K[]) {
	vi K;
	for(int i = 0; i < M; i++){
		K.pb(_K[i]);
	}
	sort(all(K));
	int Ksum = 0;
	for(int i = 0; i < M; i++){
		Ksum+=K[i];
		if(Ksum > N){
			return 0;
		}
	}

	int curind = 0;
    priority_queue<int, vector<int>, greater<int>> pq;

	for(int i = 0; i < M; i++){
		while(curind < N){
            if(students[curind].f > K[i]) break;
            pq.push(students[curind].s);
            curind++;
        }
        int need = K[i];
        while(need > 0 && sz(pq) > 0){
            int a = pq.top();
            pq.pop();
            if(a < K[i]) continue;
            need--;
        }
		if(need > 0) return 0;
	}
	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...