Submission #797238

# Submission time Handle Problem Language Result Execution time Memory
797238 2023-07-29T08:19:18 Z dimasnbayu Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define start cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define endl '\n'
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fflush(stdout); cout.flush();

/*********************************/
/*********************************/

int a[200005], b[200005];
int main(){
	start
    int n, m; cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=(m*i)-a[i];
        // if(b[i]<0) b[i]=0;
    }   
    
    vector<int>v;
    // v.push_back(0);
    for(int i=1;i<=n;i++){
        int x=b[i];
        if(x<=0) continue;
        int l=0, r=v.size()-1;
        int idx=-1;
        while(l<=r){
            int mid=(l+r)/2;
            if(x<=v[mid]){
                r=mid-1;
                idx=mid;
            }
            else l=mid+1;
        }
        if(idx!=-1) v[idx]=x;
        else v.push_back(x);
    }
    int komp=v.size();
    if(a[1]<=m) komp++;
    // if(komp==1) komp--;
    cout<<n-komp<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -