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<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
//#define double long double
vector<pii>v;
int n;
bool cmp(pii a,pii b){
if(a.s==b.s)return a.f>b.f;
return a.s<b.s;
}
void init(int N, int A[], int B[]){
n=N;
for(int i=0;i<n;i++)v.pb({A[i],B[i]});
sort(all(v),cmp);
}
int can(int m, int k[]){
multiset<pii>st;
for(int i=0;i<m;i++)st.insert({k[i],k[i]});
for(int i=0;i<n;i++){
auto it=st.lb({v[i].f,0});
if(it==st.end())continue;
pii a=(*it);
st.erase(it);
if(v[i].s>=(*it).f)a.s--;
if(a.s)st.insert(a);
}
return st.empty();
}/*
int32_t main(){
int n;cin>>n;
int a[n],b[n];
for(int i=0;i<n;i++)cin>>a[i]>>b[i];
init(n,a,b);
int q;cin>>q;
while(q--){
int m;cin>>m;
int k[m];
for(int i=0;i<m;i++)cin>>k[i];
cout<<can(m,k)<<'\n';
}
}
*/
/*
we can greedy?
sort all pair(a,b) by b
then for each k 1->m
we can find the first k[i] range that cover k[i]
we can keep doing this?
this will be (s*n) where each m in each qry can be at most n
if this work->we can do sqrt decomp?
*/
# | 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... |