Submission #1098672

# Submission time Handle Problem Language Result Execution time Memory
1098672 2024-10-09T16:41:42 Z dead0ne Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 348 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<long long,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1e15
#define MOD 1000000007
#define MX 1505
using namespace std;


void solve(){
    int n,m; cin >> n >> m;
    int arr[n+1]; 
    for(int i=1; i<=n; i++) cin >> arr[i];
    vi cur;
    for(int i=1; i<=n; i++){
        auto it=upper_bound(all(cur), arr[i]-m, greater<int>());
        if(it==cur.end()) cur.pb(arr[i]);
        else cur[it-cur.begin()]=arr[i];
    }
    cout << n-cur.size() << endl;
}

 
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif
 
    /*freopen(".in","r",stdin);
    freopen(".out","w",stdout);*/

    int t=1;
    //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -