# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741641 | MODDI | Teams (IOI15_teams) | C++14 | 4016 ms | 20340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "teams.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
vector<pii> arr;
void init(int N, int A[], int B[]) {
for(int i = 0; i < N; i++){
arr.pb(mp(A[i], B[i]));
}
// sort(arr.begin(), arr.end(), comp);
}
int can(int M, int K[]) {
vector<int> teams;
for(int i = 0; i < M; i++)
teams.pb(K[i]);
sort(teams.begin(), teams.end());
auto comp = [](pii& a, pii& b){
return (a.second == b.second) ? a.first > b.first : a.second > b.second;
};
priority_queue<pii, vector<pii>, decltype(comp)> pq(comp);
for(int i = 0; i< arr.size(); i++)
pq.push(arr[i]);
for(int i = 0; i < teams.size(); i++){
int taken = 0;
vector<pii> reuse;
while(!pq.empty() && taken < teams[i]){
pii now = pq.top();
pq.pop();
if(teams[i] < now.first || teams[i] > now.second){
reuse.pb(now);
continue;
}
taken++;
}
if(taken < i) return 0;
for(auto t : reuse)
pq.push(t);
}
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |