Submission #1010185

# Submission time Handle Problem Language Result Execution time Memory
1010185 2024-06-28T12:51:45 Z dpsaveslives Global Warming (CEOI18_glo) C++17
10 / 100
41 ms 5460 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int N,X; cin >> N >> X;
    vector<int> arr(N);
    for(int i = 0;i<N;++i){
        cin >> arr[i];
    }
    vector<int> dp(N,INT_MAX), L(N,1);
    int ans = 1;
    for(int i = 0;i<N;++i){
        int ind = lower_bound(dp.begin(),dp.end(),arr[i])-dp.begin(); //first that is >= arr[i]
        dp[ind] = arr[i];
        L[i] = ind+1;
        ans = max(ans,L[i]);
    }
    dp = vector<int>(N+1,INT_MAX);
    for(int i = N-1;i>=0;--i){ //1 to i have been decreased by X and we want to find the LDS from N-1 to i -> this is equivalent to increasing i by X
        int ind = lower_bound(dp.begin(),dp.end(),-(arr[i]+X))-dp.begin(); //we want to find the negative version so that we can still lower bound
        ans = max(ans,L[i]+ind); //no -1 because in ind, i was not counted
        ind = lower_bound(dp.begin(),dp.end(),-arr[i])-dp.begin();
        dp[ind] = -arr[i];
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 37 ms 3420 KB Output is correct
2 Correct 39 ms 5460 KB Output is correct
3 Correct 40 ms 5452 KB Output is correct
4 Correct 41 ms 5456 KB Output is correct
5 Correct 27 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1112 KB Output is correct
2 Correct 9 ms 1628 KB Output is correct
3 Correct 10 ms 1624 KB Output is correct
4 Incorrect 7 ms 1372 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -