답안 #328165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
328165 2020-11-15T13:44:19 Z Karen124 Global Warming (CEOI18_glo) C++14
17 / 100
128 ms 6636 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], b[N], ans;
pair <ll, ll> mx[N];
int main() {
    cin >> n >> add;
    for (ll i = 0; i < n; i++){
        cin >> a[i];
    }
    ll len = 0;
    for (ll i = 0; i < n; i++){
        ll p = lower_bound(b, b + len, a[i]) - b; 
        b[p] = a[i];
        len = max(len, p + 1ll);
        if (i == 0) mx[i] = {p + 1l, -a[0]};
        else mx[i] = max(mx[i - 1], {p + 1ll, -a[i]}); 
    }
    ans = len;
    fill(b, b + n + 1, 0);
    len = 0;
    for (ll i = n - 1; i >= 0; i--){
        ll p = lower_bound(b, b + len, -(a[i] + add)) - b;
        b[p] = -(a[i] + add);
        len = max(len, p + 1ll);
        if (i && a[i - 1] < a[i] + add){
            ans = max(ans, mx[i - 1].F + p + 1ll);
        }
    }
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 6636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 3436 KB Output is correct
2 Correct 54 ms 3436 KB Output is correct
3 Correct 128 ms 6512 KB Output is correct
4 Correct 84 ms 6636 KB Output is correct
5 Correct 35 ms 3436 KB Output is correct
6 Correct 72 ms 6252 KB Output is correct
7 Correct 87 ms 6252 KB Output is correct
8 Correct 51 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -