제출 #307132

#제출 시각아이디문제언어결과실행 시간메모리
307132syy로봇 (IOI13_robots)C++17
100 / 100
2053 ms33444 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++) #define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--) typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; #define f first #define s second typedef vector<ll> vi; typedef vector<pi> vpi; typedef vector<pii> vpii; #define pb push_back #define pf push_front #define all(v) v.begin(), v.end() #define INF (ll) 1e9 + 100 #define LLINF (ll) 1e18 #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) ll a, b, t, weak[50005], small[50005]; pi toy[1000005]; bool check(ll x) { priority_queue<ll> pq; ll idx = 1; FOR(i, 1, a) { while (idx <= t and toy[idx].f < weak[i]) pq.push(toy[idx++].s); FOR(j, 1, x) { if (pq.empty()) break; pq.pop(); } } while (idx <= t) pq.push(toy[idx++].s); DEC(i, b, 1) { FOR(j, 1, x) { if (!pq.empty() and pq.top() < small[i]) pq.pop(); else break; } } return pq.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A, b = B, t = T; FOR(i, 1, t) toy[i] = pi(W[i-1], S[i-1]); sort(toy+1, toy+t+1); FOR(i, 1, a) weak[i] = X[i-1]; sort(weak+1, weak+a+1); FOR(i, 1, b) small[i] = Y[i-1]; sort(small+1, small+b+1); FOR(i, 1, t) { auto it = upper_bound(weak+1, weak+a+1, toy[i].f); auto it2 = upper_bound(small+1, small+b+1, toy[i].s); if (it == weak+a+1 and it2 == small+b+1) return -1; } ll lower = 0, upper = t; while (upper - lower > 1) { ll mid = (upper + lower)/2; if (check(mid)) upper = mid; else lower = mid; } return upper; }
#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...