Submission #328176

# Submission time Handle Problem Language Result Execution time Memory
328176 2020-11-15T14:13:22 Z Karen124 Global Warming (CEOI18_glo) C++14
0 / 100
117 ms 12012 KB
#include <bits/stdc++.h>
     
using namespace std;
     
#define ll long long int 
#define F first
#define S second
#define pb push_back
#define md ((b + e) >> 1)
#define lc (ind << 1)
#define rc (lc | 1)

const ll N = 2e5 + 10;
const ll LOG = 50;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
ll n, add, a[N], L[N], R[N], ans;
pair <ll, ll> mxl[N], mxr[N];
int main() {
    cin >> n >> add;
    for (ll i = 0; i < n; i++){
        cin >> a[i];
    }
    ll lenl = 0;
    for (ll i = 0; i < n; i++){
        ll p = lower_bound(L, L + lenl, a[i]) - L; 
        L[p] = a[i];
        lenl = max(lenl, p + 1ll);
        if (i == 0) mxl[i] = {p + 1ll, -a[0]};
        else mxl[i] = max(mxl[i - 1], {p + 1ll, -a[i]}); 
    }
    ll lenr = 0;
    for (ll i = n - 1; i >= 0; i--){
        ll p = lower_bound(R, R + lenr, -(a[i] + add)) - R;
        R[p] = -(a[i] + add);
        lenr = max(lenr, p + 1ll);
        if (i == n - 1) mxr[i] = {p + 1ll, a[i] + add};
        else mxr[i] = max(mxr[i + 1], {p + 1ll, a[i] + add});
    }
    ans = max({ans, lenl, lenr});
    for (int i = 1; i < n; i++){
        if (-mxl[i - 1].S < mxr[i].S){
            ans = max(ans, mxl[i - 1].F + mxr[i].F);
            cout << "i = " << i << ' ' << mxl[i - 1].F << ' ' << mxr[i].F << '\n';
        }
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 8172 KB Output is correct
2 Correct 117 ms 8172 KB Output is correct
3 Correct 111 ms 8300 KB Output is correct
4 Correct 109 ms 8172 KB Output is correct
5 Incorrect 117 ms 12012 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2344 KB Output is correct
2 Correct 27 ms 2284 KB Output is correct
3 Correct 27 ms 2284 KB Output is correct
4 Incorrect 30 ms 3180 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 6032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -