Submission #1002604

#TimeUsernameProblemLanguageResultExecution timeMemory
1002604hasan2006Robots (IOI13_robots)C++17
76 / 100
3094 ms45128 KiB
#include <bits/stdc++.h>
#include "robots.h"


using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
    ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
    #define int long long
    sort(X , X + A);
    sort(Y , Y + B);
    vector<pair<int,int>>v;
    for(i = 0; i < T; i++){
        v.pb({W[i] , S[i]});
        if(A > 0 && X[A - 1] > W[i])
            continue;
        if(B > 0 && Y[B - 1] > S[i])
            continue;
        return -1;
    }
    sort(all(v));
    l = 1;
    r = T;
    while(l != r){
        m = (l + r) / 2;
        ll R = 0;
        multiset<pair<int,int>>st;
        for(i = 0; i < A; i++){
            while(R < v.size() && v[R].fi < X[i])
                st.insert({v[R].se , v[R].fi}),R++;
            y = m;
            while((y--) && st.size()){
                auto it = st.end();
                it--;
                st.erase(it);
            }
        }
        for(i = R; i < v.size(); i++)
            st.insert({v[i].se, v[i].fi});
        for(i = 0; i < B; i++){
            y = m;
            while((y--) && st.size() && st.begin()->fi < Y[i])
                st.erase(st.begin());
        }
        if(st.size())
            l = m + 1;
        else
            r = m;
    }
    return l;
}
/*
int main(){
    TL;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int a[] = {6 , 2 , 9};
    int b[] = {4 , 7};
    int c[] = {4 , 8 , 2 , 7 , 1 , 5 , 3 ,8 , 7 , 10};
    int d[] = {6 , 5 , 3 , 9 , 8, 1 , 3 , 7 , 6 , 5};
    cout<<putaway(3 , 2 , 10 , a , b , c  , d )<<"\n";
}*/
// Author : حسن

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:44:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             while(R < v.size() && v[R].fi < X[i])
      |                   ~~^~~~~~~~~~
robots.cpp:53:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(i = R; i < v.size(); i++)
      |                    ~~^~~~~~~~~~
robots.cpp:23:12: warning: unused variable 'j' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |            ^
robots.cpp:23:23: warning: unused variable 's' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                       ^
robots.cpp:23:31: warning: unused variable 'f' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                               ^
robots.cpp:23:35: warning: unused variable 'x' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                   ^
robots.cpp:23:43: warning: unused variable 'k' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                           ^
robots.cpp:23:47: warning: unused variable 'n' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                               ^
robots.cpp:23:54: warning: unused variable 'ans' [-Wunused-variable]
   23 |     ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
      |                                                      ^~~
#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...