제출 #151387

#제출 시각아이디문제언어결과실행 시간메모리
151387karma로봇 (IOI13_robots)C++14
76 / 100
3087 ms15932 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; vector<int> _W, _S; struct LessW { bool operator()(const int& x, const int& y) {return _W[x] < _W[y];} }; struct LessS { bool operator()(const int& x, const int& y) {return _S[x] < _S[y];} }; priority_queue<int, vector<int>, LessW> pqw; priority_queue<int, vector<int>, LessS> pqs; vector<int> BaeW, BaeS; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { // A -> W, B -> S _W.resize(T), _S.resize(T); sort(X, X + A); sort(Y, Y + B); copy(W, W + T, _W.begin()); copy(S, S + T, _S.begin()); BaeS.resize(T), BaeW.resize(T); iota(BaeS.begin(), BaeS.end(), 0); iota(BaeW.begin(), BaeW.end(), 0); sort(BaeW.begin(), BaeW.end(), [](const int& i, const int& j) { return _W[i] < _W[j]; }); sort(BaeS.begin(), BaeS.end(), [](const int& i, const int& j) { return _S[i] < _S[j]; }); int low = 1, high = T, mid, j, cur, cnt; vector<bool> del; del.resize(T); while(low <= high) { mid = (low + high) >> 1; fill(del.begin(), del.end(), 0); j = cnt = 0; while(pqs.size()) pqs.pop(); for(int i = 0; i < A; ++i) { while(_W[BaeW[j]] < X[i] && j < T) pqs.push(BaeW[j]), ++j; cur = mid; while(cur > 0 && !pqs.empty()) --cur, cnt += (del[pqs.top()] = 1), pqs.pop(); } j = 0; while(pqw.size()) pqw.pop(); for(int i = 0; i < B; ++i) { while(_S[BaeS[j]] < Y[i] && j < T) { if(!del[BaeS[j]]) pqw.push(BaeS[j]); ++j; } cur = mid; while(cur > 0 && !pqw.empty()) --cur, cnt += (del[pqw.top()] = 1), pqw.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...