제출 #47628

#제출 시각아이디문제언어결과실행 시간메모리
47628RezwanArefin01Teams (IOI15_teams)C++17
34 / 100
4054 ms57896 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std; 

int n, a[500100], b[500100]; 
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];
}

int can(int M, int K[]) {
	int S = 0; 
	for(int i = 0; i < M; i++) S += K[i];
	if(S > n) return 0;

	multiset<pair<int, int> > st; 
	for(int i = 0; i < n; i++) {
		st.insert({b[i], a[i]}); 
	}

	sort(K, K + M); 
	for(int i = 0; i < M; i++) {
		int h = K[i]; 
		for(auto it = st.begin(); it != st.end() && h; ) {
			if(it -> second <= K[i] && K[i] <= it -> first) {
				auto x = it; it++;
				st.erase(x); h--;
			} else it++;
		}
		if(h) 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...