제출 #116188

#제출 시각아이디문제언어결과실행 시간메모리
116188nvmdava로봇 (IOI13_robots)C++17
100 / 100
1791 ms24796 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; vector<pair<int, int>> toy; vector<int> w, s; int ss, ww, tt; priority_queue<int> in; bool pos(int t){ in = priority_queue<int>(); int now = 0; for(int i = 0; i < ww; i++){ while(now < tt && toy[now].first < w[i]){ in.push(toy[now].second); now++; } for(int j = 0; j < t; j++){ if(in.empty()) break; in.pop(); } } for(; now < tt; now++) in.push(toy[now].second); if(in.empty())return 1; for(int i = ss - 1; i >= 0; i--){ if(in.top() >= s[i]) return 0; for(int j = 0; j < t; j++){ in.pop(); if(in.empty()) return 1; } } if(in.empty()) return 1; return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for(int i = 0; i < T; i++) toy.push_back({W[i], S[i]}); for(int i = 0; i < A; i++) w.push_back(X[i]); for(int i = 0; i < B; i++) s.push_back(Y[i]); ss = B; ww = A; tt = T; sort(toy.begin(), toy.end()); sort(w.begin(), w.end()); sort(s.begin(), s.end()); int l = 0, r = 1000001; int m; while(l != r){ m = (l + r) >> 1; if(pos(m)) r = m; else l = m + 1; } if(r == 1000001) return -1; return 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...