제출 #123787

#제출 시각아이디문제언어결과실행 시간메모리
123787MAMBA로봇 (IOI13_robots)C++17
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define rep(i , j , k) for (int i = j; i < (int)k; i++) typedef pair<int , int> pii; const int MAXN = 1e6 + 10; int a[MAXN], w[MAXN], s[MAXN], x[MAXN], y[MAXN], fA , fB, t; priority_queue<int> st; inline bool check(int mid) { while (st.size()) st.pop(); int ptr = 0; rep(i , 0 , fA) { while (ptr < t && s[a[ptr]] < x[i]) st.push(s[a[ptr++]]); rep(j , 0 , mid) if (st.size()) st.pop(); } while (ptr < t) st.push(s[a[ptr++]]); rep(i , 0 , fB) rep(j , 0 , mid) { if (st.size() && st.top() >= y[i]) return false; if (st.size()) st.pop(); } return st.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { fA = A, fB = B,t = T; iota(a , a + T , 0); rep(i , 0 , T) w[i]= W[i], s[i] =S[i]; rep(i , 0 , A) x[i] = X[i]; rep(i , 0 , B) y[i] = Y[i]; sort(a , a + T, [](int l , int r) { return pii(w[l] , s[l]) < pii(w[r] , s[r]); }); sort(x , x + A); sort(y , y + B, greater<int>()); int lo = -1, hi = T + 1; while (lo != hi - 1) { int mid = lo + hi >> 1; if (check(mid)) hi = mid; else lo = mid; } if (hi == T + 1) hi = -1; return hi; }

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

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