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>
using namespace std;
#ifdef LOCAL
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
const int MAXN = 200005;
const int inf=1000000500ll;
const long long oo =1000000000000000500ll;
const int MOD = (int)1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> pi;
vector<pi> vec;
int n;
void init(int N, int A[], int B[]) {
n=N;
for(int i=0;i<n;i++){
vec.push_back({A[i],B[i]});
}
sort(vec.begin(),vec.end());
}
int can(int m, int K[]) {
int tot=0;
for(int i=0;i<m;i++){
tot+=K[i];
}
if(tot>n)return 0;
priority_queue<int,vector<int>,greater<int>> pq;
vector<pi> events;
for(auto x:vec){
events.push_back({x.first,x.second});
}
for(int i=0;i<m;i++){
for(int j=0;j<K[i];j++){
events.push_back({K[i],inf});
}
}
sort(events.begin(),events.end());
for(auto x:events){
while(pq.size() && pq.top() < x.first)continue;
if(x.second==inf){
if(pq.empty())return 0;
else pq.pop();
} else{
pq.push(x.second);
}
}
return 1;
}
# | 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... |