Submission #392793

#TimeUsernameProblemLanguageResultExecution timeMemory
392793SavicSRobots (IOI13_robots)C++14
0 / 100
1 ms332 KiB
#include "robots.h" #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ff(i,a,b) for(int i=a;i<=b;i++) #define fb(i,b,a) for(int i=b;i>=a;i--) using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int,int> pii; const int maxn = 1000005; const int inf = 1e9 + 5; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // os.order_of_key(k) the number of elements in the os less than k // *os.find_by_order(k) print the k-th smallest number in os(0-based) int n, m, t; int a[50005]; int b[50005]; pii toy[maxn]; bool check(int X){ // da li mogu u X minuta priority_queue<int> pq; int j = 1; ff(i,1,n){ while(j <= t && toy[j].fi <= a[i]){ pq.push(toy[j].se); j += 1; } if(pq.empty())continue; int pomX = X; while(!pq.empty() && pomX > 0){ pq.pop(); pomX -= 1; } } while(j <= t)pq.push(toy[j++].se); if(sz(pq) > X * m)return 0; ff(i,1,m){ int pomX = X; while(!pq.empty() && pomX > 0 && b[i] >= pq.top()){ pq.pop(); pomX -= 1; } } return pq.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ n = A, m = B, t = T; ff(i,1,n)a[i] = X[i - 1]; ff(i,1,m)b[i] = Y[i - 1]; ff(i,1,T)toy[i] = {W[i - 1], S[i - 1]}; sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); sort(toy + 1, toy + t + 1); int l = 0, r = inf, ans = -1; while(l <= r){ int mid = (l + r) / 2; if(check(mid)){ r = mid - 1; ans = mid; } else l = mid + 1; } return ans; } //int main() //{ // ios::sync_with_stdio(false); // cout.tie(nullptr); // cin.tie(nullptr); // cin >> n >> m >> T; // ff(i,1,n)cin >> A[i]; // ff(i,1,m)cin >> B[i]; // // ff(i,1,T)cin >> toy[i].fi; // ff(i,1,T)cin >> toy[i].se; // // sort(A + 1, A + n + 1); // sort(B + 1, B + m + 1); // sort(toy + 1, toy + T + 1); // // int l = 0, r = inf, ans = 0; // while(l <= r){ // int mid = (l + r) / 2; // if(check(mid)){ // r = mid - 1; // ans = mid; // } // else l = mid + 1; // } // // cout << ans << endl; // // return 0; //} ///** // //3 2 10 //6 2 9 //4 7 //4 8 2 7 1 5 3 8 7 10 //6 5 3 9 8 1 3 7 6 5 // //// probati bojenje sahovski ili slicno // //**/ // //
#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...