Submission #56095

# Submission time Handle Problem Language Result Execution time Memory
56095 2018-07-10T00:37:14 Z Benq Mountains (IOI17_mountains) C++14
0 / 100
3 ms 668 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int dp[2000][2000], pos[2000];

bool above(pi a, pi b, pi c) {
    b.f -= a.f, b.s -= a.s;
    c.f -= a.f, c.s -= a.s;
    return c.s*b.f-c.f*b.s >= 0;
}

int get(int l, int r) {
    if (l > r) return 0;
    return dp[l][r];
}

void ad(int x, int y) {
    pos[x] = y;
    dp[x][x] = 1;
    int sum = 1, bes = x;
    vi cur = {x};
    
    F0Rd(i,x) {
        dp[i][x] = dp[i][x-1];
        if (above({i,pos[i]},{bes,pos[bes]},{x,pos[x]})) {
            // cout << i << " " << x << "\n";
            bes = i;
            sum += get(i+1,cur.back()-1);
            cur.pb(i);
        }
        
        dp[i][x] = max(dp[i][x],sum+get(i,cur.back()-1));
    }
}

int maximum_deevs(vi v) {
    F0R(i,sz(v)) ad(i,v[i]);
    return dp[0][sz(v)-1];
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 3 ms 668 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Incorrect 2 ms 668 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 3 ms 668 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Incorrect 2 ms 668 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 3 ms 668 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Incorrect 2 ms 668 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
3 Correct 3 ms 668 KB Output is correct
4 Correct 2 ms 668 KB Output is correct
5 Incorrect 2 ms 668 KB Output isn't correct
6 Halted 0 ms 0 KB -