답안 #142928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
142928 2019-08-12T08:17:09 Z daniel920712 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include "boxes.h"
#include <stdio.h>
#include <iostream>

using namespace std;
bool have[10000005]={0};
long long delivery(int N, int K, int L, int p[])
{
    long long ans=0,t=0,how;
    int i,l=1e9+7,r=-1,j;
    for(i=0;i<N;i++)
    {
        if(p[i]<=L/2)
        {
            if((i+1)%K==0)
            {
                ans+=p[i]*2;
                for(j=i-K+1;j<=i;j++) have[j]=1;
                //printf("%lld\n",ans);
            }
        }
        else break;
    }
    for(i=N-1;i>=0;i--)
    {
        if(p[i]>L/2)
        {
            if((N-i)%K==0)
            {
                ans+=(L-p[i])*2;
                for(j=i;j-i<K;j++) have[j]=1;
                //printf("%lld\n",ans);
            }
        }
        else break;
    }
    for(j=0;j<N;j++)
    {
        if(have[j]==0)
        {
            l=min(l,j);
            r=max(r,j);
        }
    }
    t=1e18;
    if(r!=-1)
    {
        for(i=l;i<r;i++)
        {
            if((l-i+1)<=K&&(r-i)<=K) 
            {
                how=p[i]*2;
                how+=(L-p[i+1])*2;
                t=min(t,how);
            }
        }
        if((r-l+1)<=K) 
        {
            t=min(t,p[r]*2);
            t=min(t,(K-p[l])*2);
            t=min(t,L);
        }
        t=min(t,2*L);
        ans+=t;
    }
    
    return ans;

}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:59:27: error: no matching function for call to 'min(long long int&, int)'
             t=min(t,p[r]*2);
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:59:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,p[r]*2);
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:59:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,p[r]*2);
                           ^
boxes.cpp:60:31: error: no matching function for call to 'min(long long int&, int)'
             t=min(t,(K-p[l])*2);
                               ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:60:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,(K-p[l])*2);
                               ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:60:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,(K-p[l])*2);
                               ^
boxes.cpp:61:22: error: no matching function for call to 'min(long long int&, int&)'
             t=min(t,L);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:61:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,L);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:61:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
             t=min(t,L);
                      ^
boxes.cpp:63:20: error: no matching function for call to 'min(long long int&, int)'
         t=min(t,2*L);
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:63:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         t=min(t,2*L);
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from boxes.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:63:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         t=min(t,2*L);
                    ^