Submission #1057966

# Submission time Handle Problem Language Result Execution time Memory
1057966 2024-08-14T07:42:12 Z Malix Global Warming (CEOI18_glo) C++14
17 / 100
71 ms 4404 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
 
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;

int main() {
    int n,m;cin>>n>>m;
    vi a(n),b,p(n);
    REP(i,0,n)cin>>a[i];
    REP(i,0,n)a[i]=-a[i];
    reverse(a.begin(),a.end());
    b.PB(a[0]);p[0]=0;
    REP(i,1,n){
        auto it2=lower_bound(b.begin(),b.end(),a[i]+m);
        p[i]=it2-b.begin();
        auto it=lower_bound(b.begin(),b.end(),a[i]);
        if(it==b.end()){
            b.PB(a[i]);
            continue;
        }
        int pos=it-b.begin();
        b[pos]=a[i];
    }
    reverse(a.begin(),a.end());
    REP(i,0,n)a[i]=-a[i];
    reverse(p.begin(),p.end());
    b.clear();
    b.PB(a[0]);
    int k=b.size();
    int ans=k+p[0];
    REP(i,1,n){
        auto it=lower_bound(b.begin(),b.end(),a[i]);
        if(it==b.end()){
            b.PB(a[i]);k++;
            ans=max(ans,p[i]+k);
            continue;
        }
        int pos=it-b.begin();
        b[pos]=a[i];
        ans=max(ans,p[i]+k);
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1112 KB Output is correct
2 Correct 28 ms 1116 KB Output is correct
3 Correct 58 ms 2136 KB Output is correct
4 Correct 34 ms 2516 KB Output is correct
5 Correct 20 ms 2060 KB Output is correct
6 Correct 31 ms 3568 KB Output is correct
7 Correct 49 ms 4404 KB Output is correct
8 Correct 26 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -