제출 #151388

#제출 시각아이디문제언어결과실행 시간메모리
151388karma로봇 (IOI13_robots)C++14
100 / 100
2705 ms30536 KiB
#include <bits/stdc++.h> #include "robots.h" #pragma GCC optimization ("O3") #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; const int N = int(1e6) + 1; const int M = int(5e4) + 1; typedef pair<int, int> pii; vector<pii> BaeW, BaeS; vector<bool> del; priority_queue<pii> pq; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { // A -> W, B -> S sort(X, X + A); sort(Y, Y + B); for(int i = 0; i < T; ++i) BaeS.pb(S[i], i), BaeW.pb(W[i], i); sort(BaeS.begin(), BaeS.end()); sort(BaeW.begin(), BaeW.end()); int low = 1, high = T, mid, j, cur, cnt; del.resize(T); while(low <= high) { mid = (low + high) >> 1; fill(del.begin(), del.end(), 0); j = cnt = 0; while(pq.size()) pq.pop(); for(int i = 0; i < A; ++i) { while(BaeW[j].fi < X[i] && j < T) pq.push(mp(S[BaeW[j].se], BaeW[j].se)), ++j; cur = mid; while(cur > 0 && !pq.empty()) --cur, cnt += (del[pq.top().se] = 1), pq.pop(); } j = 0; while(pq.size()) pq.pop(); for(int i = 0; i < B; ++i) { while(BaeS[j].fi < Y[i] && j < T) { if(!del[BaeS[j].se]) pq.push(mp(W[BaeS[j].se], BaeS[j].se)); ++j; } cur = mid; while(cur > 0 && !pq.empty()) --cur, cnt += (del[pq.top().se] = 1), pq.pop(); } if(cnt >= T) high = mid - 1; else low = mid + 1; } return low <= T? low: -1; } // //int A, B, T, X[M], Y[M], W[N], S[N]; // //int main() //{ // ios_base::sync_with_stdio(0); // cin.tie(0), cout.tie(0); // if(fopen("test.inp", "r")) { // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); // } // cin >> A >> B >> T; // for(int i = 0; i < A; ++i) cin >> X[i]; // for(int i = 0; i < B; ++i) cin >> Y[i]; // for(int i = 0; i < T; ++i) cin >> W[i] >> S[i]; // cout << putaway(A, B, T, X, Y, W, S); //}

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

robots.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
#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...