답안 #963877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963877 2024-04-16T00:43:13 Z irmuun 로봇 (IOI13_robots) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "robots.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
    int w[A+B],s[A+B];
    for(int i=0;i<A;i++){
        w[i]=X[i];
        s[i]=2e9+1;
    }
    for(int i=A;i<A+B;i++){
        w[i]=2e9+1;
        s[i]=Y[i];
    }
    function <bool(int,int)> check=[&](int i,int j){
        if(w[i]>W[j]&&s[i]>S[j]) return true;
        return false;
    };
    if(T==2&&A+B==2){
        if(check(0,1)&&check(1,0)) return 1;
        if(check(0,0)&&check(1,1)) return 1;
        if(check(0,1)&&check(0,0)) return 2;
        if(check(0,1)&&check(1,1)) return 2;
        return -1;
    }
    if(B==0){
        sort(W,W+T);
        sort(w,w+A);
        int r=A;
        if(w[A-1]<=W[T-1]){
            return -1;
        }
        set<pair<int,int>>st;
        for(int i=T-1;i>=0;i--){
            while(r-1>=0&&w[r-1]>W[i]){
                r--;
                st.insert({0,r});
            }
            int c=st.begin()->ff,j=st.begin()->ss;
            st.erase({c,j});
            st.insert({c+1,j});
            ans=max(ans,c+1);
        }
        return ans;
    }
    return -1;
}

Compilation message

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:50:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |             ans=max(ans,c+1);
      |             ^~~
      |             abs
robots.cpp:52:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |         return ans;
      |                ^~~
      |                abs