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;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
ll n;
vi a;
vi b;
void init(int N, int A[], int B[]) {
n = N;
a.resize(n);
b.resize(n);
rep(i,0,n) {
a[i] = A[i]-1;
b[i] = B[i]-1;
}
}
int can(int M, int K[]) {
vi k;
k.assign(n,0);
rep(i,0,M) k[K[i]-1] += K[i];
vi add(n+1);
vector<vi> ends(n);
rep(i,0,n){
ends[a[i]].push_back(b[i]+1);
add[a[i]]++;
add[b[i]+1]--;
}
ll sum = 0;
multiset<ll> currEnds;
rep(i,0,n){
while(currEnds.size()&&*currEnds.begin()==i){
currEnds.erase(currEnds.begin());
}
sum+=add[i];
rep(j,0,ends[i].size()) currEnds.insert(ends[i][j]);
if(k[i]>sum) {
//cout<<0<<endl;
return 0;
}
sum-=k[i];
rep(j,0,k[i]){
add[*currEnds.begin()]++;
currEnds.erase(currEnds.begin());
}
}
//cout<<1<<endl;
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... |