제출 #740239

#제출 시각아이디문제언어결과실행 시간메모리
740239Dan4Life로봇 (IOI13_robots)C++17
14 / 100
1621 ms23196 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() const int mxN = (int)5e4+10; int n, m, t, x[mxN], y[mxN]; struct Toy{ int w, s; }; vector<Toy> toy; bool chk(int tim){ priority_queue<int> pq; while(sz(pq))pq.pop(); for(int i = 0, j = 0; i < n; i++){ while(j<t and toy[j].w<x[i]) pq.push(toy[j++].s); int xd = tim; while(xd-- and sz(pq)) pq.pop(); if(i==n-1) while(j<t) pq.push(toy[j++].s); } for(int i = m-1; i >= 0; i--){ int xd = tim; while(xd-- and sz(pq)){ if(pq.top()>=y[i]) return 0; pq.pop(); } } return !sz(pq); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n = A, m = B, t = T; for(int i = 0; i < n; i++) x[i] = X[i]; for(int i = 0; i < m; i++) y[i] = Y[i]; for(int i = 0; i < t; i++) toy.pb({W[i],S[i]}); sort(x,x+n), sort(y,y+m); sort(begin(toy),end(toy),[&](Toy a, Toy b){return a.w<b.w;}); int l = 0, r = t; while(l<r){ int mid = (l+r)/2; if(chk(mid)) r=mid; else l=mid+1; } if(chk(l)) return l; return -1; }
#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...