답안 #129809

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
129809 2019-07-13T09:37:47 Z DodgeBallMan 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "boxes.h"

using namespace std;

const int N = 1e6 + 10;
long long ans = 1e18, dpr[N], dpl[N], n, k, l, p[N];

long long delivery( int N, int K, int L, int P[] ) {
    n = ( long long )N, k = ( long long )K, l = ( long long )L;
    for( int i = 1 ; i <= n ; i++ ) p[i] = ( long long )P[i-1];
    for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
    for( int i = n ; i >= 1 ; i-- ) dpl[i] = l - p[i] * 2LL + dpl[min( l + 1, i + k )];
    for( int i = 0 ; i <= n ; i++ ) ans = min( ans, dpr[i] + dpl[i+1] );
    return ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:9:50: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 long long delivery( int N, int K, int L, int P[] ) {
                                                  ^
boxes.cpp:6:11: note: shadowed declaration is here
 const int N = 1e6 + 10;
           ^
boxes.cpp:12:77: error: no matching function for call to 'max(int, long long int)'
     for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
                                                                             ^
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
boxes.cpp:12:77: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
                                                                             ^
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/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
boxes.cpp:12:77: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
     for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:12:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:12:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     for( int i = 1 ; i <= n ; i++ ) dpr[i] = p[i] * 2LL + dpr[max( 0, i - k )];
                                                                             ^
boxes.cpp:13:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     for( int i = n ; i >= 1 ; i-- ) dpl[i] = l - p[i] * 2LL + dpl[min( l + 1, i + k )];
                  ^