답안 #1096682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096682 2024-10-05T02:21:25 Z nguyenvu Global Warming (CEOI18_glo) C++14
10 / 100
2000 ms 5516 KB
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define FILE "DAYDEP"
using namespace std;
int n,x;
ll a[200005],dp[200005];

void sub2()
{
    for(int i=1;i<=n;i++) dp[i]=10000000000;
    int ans=0;
    for(int i=1;i<=n;i++){
        int k=lower_bound(dp+1,dp+n+1,a[i])-dp;
        dp[k]=a[i];
        ans=max(ans,k);
    }
    cout<<ans;
}

void solve()
{
    int ans=0;
    for(int i=1;i<n;i++){
        int cnt=1;
        ll mx=-1e9;
        int d=0;
        for(int j=i+1;j<=n;j++){
            if(a[j]>a[i]){
                cnt++;
                mx=max(mx,a[i]);
            }
            else{
                int dem=0;
                if(a[j]+x<=mx) continue;
                for(int k=j+1;k<=n;k++){
                    if(a[k]+x>mx) mx=a[k],dem++;
                }
                mx=a[j];
                d=max(d,dem);
            }
        }
        cnt+=d;
        ans=max(d,ans);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(FILE".inp","r",stdin);
    //freopen(FILE".out","w",stdout);
    cin>>n>>x;
    for(int i=1;i<=n;i++) cin>>a[i];
    if(x==0) sub2();
    else solve();
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 5464 KB Output is correct
2 Correct 25 ms 5464 KB Output is correct
3 Correct 24 ms 5464 KB Output is correct
4 Correct 23 ms 5516 KB Output is correct
5 Correct 17 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2060 ms 1312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2067 ms 2140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -