Submission #309690

#TimeUsernameProblemLanguageResultExecution timeMemory
309690amunduzbaevRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include "robots.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int N1=5e4+5;
int t,a,b,a1[N1],b1[N1],w[N],s[N];
int used[N1];
bool check(int m){
    for(int i=0;i<t;i++){
        int l=0,r=a-1;
        while(l<r){
            int mid=(l+r)/2;
            if(al[mid]>=w[i])
                r=mid;
            else
                l=mid+1;
        }
        while(used[l]==m&&l<a)
            l++;
        if(l==a&&used[l]==m)
            return 0;
        used[l]++;
    }
    return 1;

}
int putaway(int A, int B, int T, int A1[], int B1[], int W[], int S[]) {
    t=T,a=A,b=B;
    for(int i=0;i<t;i++){
        w[i]=W[i];
        s[i]=S[i];
    }
    for(int i=0;i<a;i++) a1[i]=A1[i];
    for(int i=0;i<b;i++) b1[i]=B1[i];
    sort(a1,a1+a);
    sort(b1,b1+b);
    for(int i=0;i<t;i++){
        if(a&&b){
            if(w[i]>=a1[a-1]&&s[i]>=b1[b-1]) return -1;
        }else if(a){
            if(w[i]>=a1[a-1]) return -1;
        }else{
            if(s[i]>=b1[b-1]) return -1;
        }
    }
    if(t==2){
        if(a>0&&b>0){
            return (a1[0]>w[0]&&b1[0]>s[1]||a1[0]>w[1]&&b1[0]>s[0]) ? 1 : 2 ;
        }
        if(a>0){
            return (a1[0]>w[0]&&a1[1]>w[1]||a1[1]>w[0]&&a1[0]>w[1]) ? 1 : 2 ;
        }
        if(b>0){
            return (b1[0]>s[0]&&b1[1]>s[1]||b1[1]>s[0]&&b1[0]>s[1]) ? 1 : 2 ;
        }
    }
    int l=1,r=t;
    while(l<r){
        int m=(l+r)/2;
        if(check(m))
            r=m;
        else
            l=m+1;
    }
    return l;

}

Compilation message (stderr)

robots.cpp: In function 'bool check(int)':
robots.cpp:14:16: error: 'al' was not declared in this scope; did you mean 'l'?
   14 |             if(al[mid]>=w[i])
      |                ^~
      |                l
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:49:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   49 |             return (a1[0]>w[0]&&b1[0]>s[1]||a1[0]>w[1]&&b1[0]>s[0]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~
robots.cpp:52:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   52 |             return (a1[0]>w[0]&&a1[1]>w[1]||a1[1]>w[0]&&a1[0]>w[1]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~
robots.cpp:55:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   55 |             return (b1[0]>s[0]&&b1[1]>s[1]||b1[1]>s[0]&&b1[0]>s[1]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~