제출 #1309251

#제출 시각아이디문제언어결과실행 시간메모리
1309251avohado선물상자 (IOI15_boxes)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
#define mod 1000000007
#define maxn 200005
#define f first
#define s second
#define ll long long
#define pb(x) push_back(x)
#define mp make_pair
#define all(x) x.begin(), x.end()
#define len(v) max(0, (int)v.size())
long long delivery(int N, int k, int L, int p[]){
    vector<int> l, r;
    long long ans1=0, ans2=0;
    for(int i=0; i<N; i++){
        if(p[i]<(L+1)/2){
            l.pb(p[i]);
        }else{
            r.pb(L-p[i]);
        }
    }
    int i=0;
    while(i<len(l)){
        int d=min(k, len(l)-i);
        ans1+=l[i-1+d]*2;
        i+=d;
    }
    i=0;
    while(i<len(r)){
        int d=min(k, len(r)-i);
        ans1+=l[i-1+d]*2;
        i+=d;
    }
    if(n<=k){
        return min(ans1, L);
    }
    if(min(len(l), len(r))==0){
        return ans1;
    }
    ans2=ans1;
    i=min(0, len(l)-k);
    ans1-=l[len(l)-1]*2;
    if(i%k!=0){
        ans1+=(l[i-1]*2);
    }
    j=len(r)-1;
    if(len(l)<k){
        j-=k-len(l);
        ans1-=r[len(r)-1]*2;
        if(j%k!=0){
            ans1+=r[j-1]*2;
        }
    }
    while(i<len(l)&&j>=0){
        ans2=min(ans1, ans2);
        ans1+=l[i]*2;
        ans1-=r[i]*2;
        if(i%k!=1&&i!=0){
            ans1-=l[i-1]*2;
        }
        if(j%k!=1&&j!=0){
            ans2+=r[j-1];
        }
        i++;j--;
    }
    return min(ans1, ans2);
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:35:8: error: 'n' was not declared in this scope
   35 |     if(n<=k){
      |        ^
boxes.cpp:36:19: error: no matching function for call to 'min(long long int&, int&)'
   36 |         return min(ans1, L);
      |                ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from boxes.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |         return min(ans1, L);
      |                ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |         return min(ans1, L);
      |                ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |         return min(ans1, L);
      |                ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
boxes.cpp:36:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |         return min(ans1, L);
      |                ~~~^~~~~~~~~
boxes.cpp:47:5: error: 'j' was not declared in this scope
   47 |     j=len(r)-1;
      |     ^