Submission #960018

#TimeUsernameProblemLanguageResultExecution timeMemory
9600188pete8Teams (IOI15_teams)C++17
34 / 100
4041 ms9168 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...