# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
114319 | MohamedAhmed04 | 로봇 (IOI13_robots) | C++14 | 955 ms | 24892 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std ;
const int MAX = 50005 ;
int n , m ;
int Weight[MAX] , Size[MAX] ;
vector< vector<int> >appear ;
//the check function that return true if robots can put away toys in mid second and otherwise it will return false
bool check(int mid)
{
priority_queue<int>q ;
//put away toys using weak robots.
for(int i = 0 ; i < n ; ++i)
{
for(int j = 0 ; j < appear[i].size() ; ++j)
q.push(appear[i][j]) ;
int sz = q.size() ;
for(int j = 0 ; j < min(sz , mid) ; ++j)
q.pop() ;
}
//handle case for toys that their weight is more than all weak robots weight.
for(int j = 0 ; j < appear[n].size() ; ++j)
q.push(appear[n][j]) ;
//put away remaining toys using small robots.
for(int i = 0 ; i < m ; ++i)
{
int sz = q.size() ;
for(int j = 0 ; j < min(sz , mid) ; ++j)
{
int a = q.top() ;
if(a >= Size[i])
break;
q.pop() ;
}
}
if(q.empty())
return 1 ;
return 0 ;
}
int putaway(int A , int B , int T , int X[] , int Y[] , int W[] , int S[])
{
for(int i = 0 ; i < A ; ++i)
Weight[i] = X[i] ;
for(int i = 0 ; i < B ; ++i)
Size[i] = Y[i] ;
sort(Weight , Weight + A) ;
sort(Size , Size + B) ;
n = A , m = B ;
appear.resize(A+1) ;
for(int i = 0 ; i < T ; ++i)
{
int idx1 = upper_bound(Weight , Weight + A , W[i]) - Weight ;
int idx2 = upper_bound(Size , Size + B , S[i]) - Size ;
//if current toy weight is bigger than weight of all weak robots and its size is more than size of all small robots
if(idx1 == A && idx2 == B)
return -1 ;
appear[idx1].push_back(S[i]) ;
}
reverse(Size , Size + B) ;
for(int i = 0 ; i <= n ; ++i)
{
if(appear[i].size() == 0)
continue ;
sort(appear[i].begin() , appear[i].end() , greater<int>());
}
//make binary search
int l = 1 , r = T , ans;
while(l <= r)
{
int mid = (l + r) / 2 ;
if(check(mid))
r = mid-1 , ans = mid;
else
l = mid+1 ;
}
return ans ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |