Submission #13291

# Submission time Handle Problem Language Result Execution time Memory
13291 2015-02-10T08:32:26 Z gs14004 Skyline (IZhO11_skyline) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <algorithm>
using namespace std;

int a[305],n;
int dp[305][205][205];

int f(int pos, int p1, int p2){
    if(pos == n) return 0;
    int p3 = a[pos+2];
    int ret = f(pos+1,p2,p3) + 3 * p1;
    if(pos + 1 < n){
        int cut = min(p1,p2);
        ret = min(ret,f(pos+1,p2-cut,p3) + 5 * cut, 3 * (p1 - cut));
    }
    if(pos + 2 < n){
        int cut = min(p1,min(p2,p3));
        ret = min(ret,f(pos+1,p2-cut,p3-cut) + 7 * cut + 3 * (p1 - cut));
    }
    return dp[pos][p1][p2] = ret;
}

int main(){
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    printf("%d",f(0,a[0],a[1]));
}

Compilation message

In file included from /usr/include/c++/4.9/algorithm:61:0,
                 from skyline.cpp:2:
/usr/include/c++/4.9/bits/stl_algobase.h: In instantiation of ‘const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]’:
skyline.cpp:14:67:   required from here
/usr/include/c++/4.9/bits/stl_algobase.h:243:26: error: ‘__comp’ cannot be used as a function
       if (__comp(__b, __a))
                          ^
skyline.cpp: In function ‘int main()’:
skyline.cpp:24:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
skyline.cpp:26:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^