Submission #281788

#TimeUsernameProblemLanguageResultExecution timeMemory
281788shayan_pRobots (IOI13_robots)C++14
100 / 100
1869 ms13048 KiB
// And you curse yourself for things you never done #include<bits/stdc++.h> #include "robots.h" #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int maxn = 1e6 + 10, mod = 1e9 + 7, inf = 1e9 + 10; int putaway(int n, int m, int T, int X[], int Y[], int XX[], int YY[]){ vector<pii> v; for(int i = 0; i < T; i++) v.PB({XX[i], YY[i]}); sort(v.begin(), v.end()); sort(X, X+n), sort(Y, Y+m); int l = 0, r = T+1; while(r-l > 1){ bool bad = 0; int mid = (l+r) >> 1; priority_queue<int> pq; int pt = 0; for(int i = 0; i < n; i++){ while(pt < T && v[pt].F < X[i]) pq.push(v[pt].S), pt++; int SZ = max(int(0), sz(pq) - mid); while(sz(pq) > SZ) pq.pop(); } while(pt < T) pq.push(v[pt].S), pt++; for(int i = m-1; i >= 0; i--){ int SZ = max(int(0), sz(pq)-mid); while(sz(pq) > SZ) bad|= pq.top() >= Y[i], pq.pop(); } bad|= sz(pq); if(bad) l = mid; else r = mid; } return (r == T+1 ? -1 : r); }
#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...