제출 #787738

#제출 시각아이디문제언어결과실행 시간메모리
787738drdilyor로봇 (IOI13_robots)C++17
0 / 100
1 ms212 KiB
#include "robots.h" #include <algorithm> #include <iostream> #include <cassert> #include <numeric> #include <set> using namespace std; int putaway(int wrobot, int srobot, int n, int rw[], int rs[], int w[], int s[]) { sort(rw, rw + wrobot); sort(rs, rs + srobot); auto comp_w = [&](int i, int j)->bool{ return w[i] < w[j]; }; auto comp_s = [&](int i, int j)->bool{ return s[i] < s[j]; }; int* byw = new int[n]; int* bys = new int[n]; iota(byw, byw + n, 0); iota(bys, bys + n, 0); sort(byw, byw + n, comp_w); sort(bys, bys + n, comp_s); auto check = [&](int time)->bool { cout <<time << endl; int* done = new int[n]; { int toy = 0; set<pair<int,int>> st; for (int rob = 0; rob < wrobot; rob++) { while (toy < n && w[byw[toy]] < rw[rob]) { st.insert({-s[toy], toy}); toy++; } for (int rem = 0; rem < time && st.size(); rem++) { done[st.begin()->second] = 1; st.erase(st.begin()); } } } { int toy = 0; set<pair<int,int>> st; for (int rob = 0; rob < srobot; rob++) { while (toy < n && s[bys[toy]] < rs[rob]) { if (!done[toy]) st.insert({-w[toy], toy}); toy++; } for (int rem = 0; rem < time && st.size(); rem++) { done[st.begin()->second] = 1; st.erase(st.begin()); } } } int all_done = accumulate(done, done + n, 0); return all_done == n; }; int l = -1, r = n +1; while (l < r - 1) { int mid = (l + r) / 2; if (check(mid)) r = mid; else l = mid; } return r == n+1 ? -1 : r; }
#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...