답안 #397803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397803 2021-05-03T06:44:05 Z iANikzad Global Warming (CEOI18_glo) C++14
0 / 100
64 ms 8740 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cerr<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 5e5 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;

int a[maxn];

int L[maxn], R[maxn];
int dp[maxn], pd[maxn];

int32_t main()
{
    FAST;

    int n, x;
    cin >> n >> x;

    for(int i = 1; i <= n; i++)
        cin >> a[i], dp[i] = pd[i] = +INF;

    for(int i = 1; i <= n; i++)
    {
        int pos = lower_bound(dp + 1, dp + 1 + n, a[i]) - dp;
        L[i] = pos + 1;

        dp[pos] = a[i];
    }

    for(int i = n; i > 0; i--)
    {
        int pos = lower_bound(pd + 1, pd + 1 + n, -a[i] + x) - pd;
        R[i] = pos + 1;

        int npos = lower_bound(pd + 1,pd + 1 + n, -a[i]) - pd;
        dp[npos] = -a[i];
    }

    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, R[i] + L[i] - 1);

    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 8740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 4916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -