Submission #172373

# Submission time Handle Problem Language Result Execution time Memory
172373 2020-01-01T12:21:40 Z 79brue Mountains (IOI17_mountains) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n;
ll arr[2002];

bool canSee[2002][2002];
ll DP[2002][2002];
ll ans;

int main(){
    scanf("%lld", &n);
    for(ll i=1; i<=n; i++) scanf("%lld", &arr[i]);

    for(ll i=1; i<=n; i++){
        ll x=1, y=-1e9-1;
        for(ll j=i+1; j<=n; j++){
            if(y*(j-i) <= x*(arr[j]-arr[i])){
                canSee[i][j] = canSee[j][i] = 1;
                x=j-i, y=arr[j]-arr[i];
            }
        }
    }

    for(ll j=1; j<=n; j++){
        ll tmp = 1, l = 0;
        DP[j][j] = 1;
        for(ll i=j-1; i>=1; i--){
            if(canSee[i][j]){
                if(l) tmp += DP[i+1][l], l=0;
                l = 0;
                DP[i][j] = tmp;
            }
            else{
                if(!l) l=i;
                DP[i][j] = tmp + DP[i][l];
            }
            ans = max(ans, DP[i][j]);
//            printf("%lld %lld: %lld\n", i, j, DP[i][j]);
        }
    }

    printf("%lld", ans);
}

Compilation message

mountains.cpp: In function 'int main()':
mountains.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
mountains.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(ll i=1; i<=n; i++) scanf("%lld", &arr[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~
/tmp/ccOwCpy2.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cchMTxE8.o:mountains.cpp:(.text.startup+0x0): first defined here
/tmp/ccOwCpy2.o: In function `main':
grader.cpp:(.text.startup+0x20a): undefined reference to `maximum_deevs(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status