Submission #1002677

#TimeUsernameProblemLanguageResultExecution timeMemory
1002677hasan2006Robots (IOI13_robots)C++17
76 / 100
3091 ms42680 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;
    sort(X , X + A);
    sort(Y , Y + B);
    vector<pair<int,int>>v;
    swap(A , B);
    swap(X , Y);
    swap(S , W);
    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 = T / (A + B);
    r = T;
    while(l != r){
        m = (l + r) / 2;
        ll R = 0;
        multiset<int>st;
        for(i = 0; i < A; i++){
            while(R < v.size() && v[R].fi < X[i])
                st.insert(v[R].se),R++;
            y = m;
            while((y--) && st.size())
                st.erase(--st.end());
        }
        for(i = R; i < v.size(); i++)
            st.insert(v[i].se);
        for(i = 0; i < B; i++){
            y = m;
            while((y--) && st.size() && *st.begin() < Y[i])
                st.erase(st.begin());
        }
        if(st.size())
            l = m + 1;
        else
            r = m;
    }
    return l;
}

Compilation message (stderr)

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