제출 #1255952

#제출 시각아이디문제언어결과실행 시간메모리
1255952_unknown_2010Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
22 ms8124 KiB
//#ifndef khos
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef khos
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using indexed_multiset = tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;

#define int int64_t
#define vi vector
#define ss second
#define ff first
#define TESTCASES
#define all(x) (x).begin(), (x).end()
const int mod = 1e9+7;
const int MAXN=2000000+5;
const int inf=1e18;
int lis(vi<int> a){
    debug(a);
    vi<int> vec;
    for(int i=0; i<a.size(); i++){
        int hi=upper_bound(all(vec), a[i]) - vec.begin();
        if(hi==vec.size()){
            vec.push_back(a[i]);
        }
        else {
            vec[hi]=a[i];
        }
    }
    return vec.size();
}
void solution() {
    int n,m;
    cin >> n >> m;
    vi<int> a(n+1);
    for(int i=1; i<=n; i++)cin >> a[i];
    vi<int> vec;
    for(int i=1; i<=n; i++){
        if(i*m>=a[i]){
            vec.push_back(i*m-a[i]);
        }
    }
    cout << n-lis(vec);
}
int32_t main(){
    clock_t tStart = clock();
    // freopen("cowjog.in", "r", stdin);
    // freopen("cowjog.out", "w", stdout);
    #ifdef khos
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    #ifdef TESTCASES
        // cin >> q;
    #endif
    while(q--) {
        solution();
        cout << '\n';
    }
    cerr<<fixed<<setprecision(3)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...