# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726668 | TheSahib | Teams (IOI15_teams) | C++17 | 4033 ms | 38948 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 <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
int n;
vector<pii> v;
void init(int N, int A[], int B[])
{
n = N;
for (int i = 0; i < n; i++)
{
v.push_back({A[i], B[i]});
}
}
int can(int M, int K[])
{
sort(K, K + M);
vector<pii> events[n + 1];
for (int i = 0; i < n; i++)
{
events[v[i].first].push_back({0, i});
if(v[i].second + 1 <= n){
events[v[i].second + 1].push_back({1, i});
}
}
int j = 0;
multiset<pii> s;
for (int x = 0; x <= n && j < M; x++)
{
for(auto& e:events[x]){
if(e.first == 0){
s.insert({v[e.second].second, v[e.second].first});
}
else{
auto itr = s.find({v[e.second].second, v[e.second].first});
if(itr != s.end()){
s.erase(itr);
}
}
}
while(x == K[j]){
if(s.size() < K[j]){
return false;
}
for (int i = 0; i < K[j]; i++)
{
s.erase(s.begin());
}
++j;
if(j == M) break;
}
}
return true;
}
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... |