제출 #1078025

#제출 시각아이디문제언어결과실행 시간메모리
1078025TheQuantiX로봇 (IOI13_robots)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; using ll = long long; ll n, m, q, k, x, y, a, b, c; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector< pair<ll, ll> > v; for (int i = 0; i < T; i++) { v.push_back({W[i], S[i]}); } sort(v.begin(), v.end()); sort(X, X + A); sort(Y, Y + B); if (B == 0) { int ans = 0; int cnt = 0; int pos = 0; for (int i = 0; i < A; i++) { int ocnt = cnt; while (pos != T && v[pos].first < X[i]) { cnt++; pos++; } ans = max(ans, cnt / (i + 1) + ((cnt % (i + 1)) > 0)); ans = max(ans, cnt - ocnt); } if (pos != T) { return -1; } return ans; } ll l = T / (A + B), r = T + 1; while (r > l) { ll mid = (r + l) / 2; // cout << mid << endl; ll pos = 0; multiset<ll> st; for (int i = 0; i < A; i++) { while (pos != T && v[pos].first < X[i]) { st.insert(v[pos].second); pos++; } for (int j = 0; j < mid; j++) { if (st.size() == 0) { break; } // cout << i << ' ' << *st.rbegin() << endl; st.erase(--st.end()); } } while (pos != T) { st.insert(v[pos].second); pos++; } // cout << st.size() << endl; bool fl = 1; for (int i = B - 1; i >= 0; i--) { if (st.empty()) { break; } if ((*st.rbegin()) >= Y[i]) { fl = 0; break; } for (int j = 0; j < mid; j++) { if (st.size() == 0) { break; } st.erase(--st.end()); } } if (st.size() != 0) { fl = 0; } if (fl) { r = mid; } else { l = mid + 1; } } if (l == T + 1) { return -1; } return l; }
#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...