제출 #945049

#제출 시각아이디문제언어결과실행 시간메모리
945049oblantis로봇 (IOI13_robots)C++17
90 / 100
774 ms31160 KiB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define pb push_back #define ss second #define ff first #define vt vector using namespace std; typedef long long ll; typedef pair<int, int> pii; const int inf = INT_MAX; const int mod = 1e9+7; const int maxn = 5002; #include "robots.h" int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { int l = 0, r = t + 1; vt<pii> v; set<int> S; for(int i = 0; i < b; i++){ S.insert(y[i]); } map<int, int> toc; int id = 0; for(auto i : S)toc[i] = id++; for(int i = 0; i < a; i++){ v.pb({x[i] - 1, inf}); } for(int i = 0; i < t; i++){ if(S.upper_bound(s[i]) == S.end())s[i] = b; else s[i] = toc[*S.upper_bound(s[i])]; v.pb({w[i], s[i]}); } sort(all(v)); while(l + 1 < r){ int mid = l + (r - l) / 2; priority_queue<int> pq; bool ok = 1; for(int i = 0; i < t + a; i++){ if(v[i].ss == inf){ for(int j = 0; j < mid && !pq.empty(); j++)pq.pop(); } else { pq.push(v[i].ss); } } for(int i = b - 1; !pq.empty() && i >= 0; i--){ if(pq.top() > i){ ok = 0; break; } for(int j = 0; !pq.empty() && j < mid; j++)pq.pop(); } if(!pq.empty())ok = 0; if(ok)r = mid; else l = mid; } if(r > t)return -1; return r; } //int main() { //ios_base::sync_with_stdio(0); //cin.tie(0); //int a, b, t; //cin >> a >> b >> t; //int x[a], y[b], w[t], s[t]; //for(int i = 0; i < a; i++)cin >> x[i]; //for(int i = 0; i < b; i++)cin >> y[i]; //for(int i = 0; i < t; i++)cin >> w[i] >> s[i]; //cout << putaway(a, b, t, x, y, w, s); //return 0; //}
#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...