Submission #957583

#TimeUsernameProblemLanguageResultExecution timeMemory
957583vjudge1Robots (IOI13_robots)C++17
0 / 100
2 ms4696 KiB
#include <bits/stdc++.h> using namespace std; #define sst string #define REP(i,x,y) for(ll i=x;i<=y;i++) #define freeopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #define mod 1000000007 #define pb push_back #define mk make_pair #define ll long long #define foor(x,vec) for(auto x:vec ){cout<<x<<" ";} #define fi first #define se second #define MAXN 1000069 #define lld long double #define cha ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ffl fflush(stdout) #define pii pair<ll,ll> ll mvx[]={1,-1,0,0}; ll mvy[]={0,0,-1,1}; #include "robots.h" int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { vector <pii> vec; for(ll i=0;i<a;i++){ vec.pb({x[i],1}); } for(ll i=0;i<t;i++){ vec.pb({w[i],s[i]}); } sort(vec.begin(),vec.end()); sort(y,y+b,greater<int>()); int l=0; int r=t+1; int ans=-1; while(l<r){ int md=(l+r)>>1; bool ok=1; priority_queue<pii>pq; for(int i=0;i<(int)vec.size();i++){ if(vec[i].se==1){ for(int j=0;j<md;j++){ if(pq.size())pq.pop(); } } else{ pq.push(vec[i]); } } priority_queue<ll> pq2; while(pq.size()){ pq2.push(pq.top().se); pq.pop(); } for(int i=0;i<b;i++){ if(!pq2.size())break; if(pq2.top()>=y[i]){ ok=0; break; } else{ for(int j=0;j<md;j++){ if(pq2.size())pq2.pop(); } } } if(ok){ ans=md; r=md; } else{ l=md+1; } } return ans; } /* ---------------------------------------------------go get gold--------------------------------------------------------------------- - If u see the problem dp there's many option to iterate, u can iterate from 1- n or 1 - (possible max number) - If u see the problem that has unexpected constraint u can divide it into 2 problem - If u see the problem that can use binary search, then u can use binser + check condition - in interactive problem there's many trick using binser - kalo misal mau cari yang sama pake pernah ke visit ga bilangan itu - kalo problem yang high itu biasanya optimisasi nya pake 2 array - dp bisa aja kek kamu tenzing balls dimana optimisasi 2 dp - janlup fibonacci - kalo binser mending r = 3 * 1e18 aja - kalo mau dibalik itu pake value nya tinggal diubah ke size */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...