제출 #816301

#제출 시각아이디문제언어결과실행 시간메모리
816301makanhulia로봇 (IOI13_robots)C++17
100 / 100
1432 ms19036 KiB
#include"robots.h" #include<bits/stdc++.h> using namespace std; int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { vector<pair<int, int>> toy(t); for(int i=0; i<t; i++) toy[i]={w[i], s[i]}; sort(toy.begin(), toy.end()); sort(x, x+a); sort(y, y+b); auto can = [&](int lim) -> bool { int idx=0; priority_queue<int> pq; for(int i=0; i<a; i++) { while(idx<t && toy[idx].first<x[i]) pq.push(toy[idx++].second); for(int j=0; j<lim && !pq.empty(); j++) pq.pop(); } while(idx<t) pq.push(toy[idx++].second); for(int i=b-1; i>=0; i--) { for(int j=0; j<lim && !pq.empty(); j++) { if(pq.top()>=y[i]) return 0; pq.pop(); } } return pq.empty(); }; int l=1, r=t, ans=t+1; while(l<=r) { int mid=l+r>>1; if(can(mid)) r=mid-1, ans=mid; else l=mid+1; } return (ans<=t ? ans : -1); }

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:27:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |     int mid=l+r>>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...