Submission #416208

# Submission time Handle Problem Language Result Execution time Memory
416208 2021-06-02T07:32:06 Z duyanh1704 Global Warming (CEOI18_glo) C++14
0 / 100
57 ms 8088 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int inf = 1e17 + 29;
int n, x, res;
vector<int> a;

vector<int> LIS(vector<int> a, int t){
    vector<int> f(n + 5, inf); f[0] = -inf;
    vector<int> dp(n, 0);
    for (int i = 0; i < n; ++i){
        int k = lower_bound(f.begin(), f.end(), t * a[i]) - f.begin();
        dp[i] = k;
        f[k] = t * a[i];
    }
    return dp;
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> x;
    for (int i = 1; i <= n; ++i){
        int t; cin >> t;
        a.push_back(t);
    }


    vector<int> f = LIS(a, 1);
    reverse(a.begin(), a.end());
    vector<int> g = LIS(a, -1);
    reverse(g.begin(), g.end());

    int dec = 0;
    for (int i = 0; i < n; ++i){
        res = max(res, f[i] + dec - 1);
        dec = max(g[i], dec);
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 8088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 4256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -