제출 #1064574

#제출 시각아이디문제언어결과실행 시간메모리
1064574ArthuroWich로봇 (IOI13_robots)C++17
0 / 100
3088 ms27856 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; int n, m, t; vector<int> weak, small; vector<pair<int, int>> toy; bool check(int x) { priority_queue<pair<int, int>> pq; queue<pair<int, int>> q; for (auto c : toy) { pq.push(c); } for (int i : weak) { while(!q.empty()) { pq.push(q.front()); q.pop(); } int co = x; while(!pq.empty() && co > 0) { auto [s, w] = pq.top(); pq.pop(); if (w < i) { co--; } else { q.push({s, w}); } } } for (int i : small) { int co = x; while(!pq.empty() && co > 0) { auto [s, w] = pq.top(); pq.pop(); if (s < i) { co--; } else { return 0; } } } if (pq.empty()) { return 1; } else { return 0; } } 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 < t; i++) { toy.push_back({S[i], W[i]}); } for (int i = 0; i < n; i++) { weak.push_back(X[i]); } for (int i = 0; i < m; i++) { small.push_back(Y[i]); } int l = 1, r = T; sort(toy.rbegin(), toy.rend()); sort(weak.begin(), weak.end()); sort(small.rbegin(), small.rend()); while(l < r) { int m = (l+r)/2; if (check(m)) { r = m; } else { l = m+1; } } if (check(l)) { return l; } else { 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...