Submission #416202

# Submission time Handle Problem Language Result Execution time Memory
416202 2021-06-02T07:11:26 Z duyanh1704 Global Warming (CEOI18_glo) C++14
0 / 100
51 ms 8120 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 k){
    vector<int> f(n + 5, inf); f[0] = -inf;
    vector<int> dp(n, 0);
    f[0] = -inf;
    for (int i = 0; i < n; ++i){
        int k = lower_bound(f.begin(), f.end(), k * a[i]) - f.begin();
        dp[i] = k;
        f[k] = k * 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());

    for (int i = 0; i < n; ++i)
        res = max(res, f[i] + g[i] - 1);
    cout << res;
}

Compilation message

glo.cpp: In function 'std::vector<long long int> LIS(std::vector<long long int>, long long int)':
glo.cpp:14:51: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |         int k = lower_bound(f.begin(), f.end(), k * a[i]) - f.begin();
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 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 1 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 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 8120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 4228 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 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -