| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1068101 | HUYHDUVE | Rabbit Carrot (LMIO19_triusis) | C++14 | 1 ms | 348 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//  ^------^
// ( '(oo)' )
// (  u  u  )
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IN "A.IN"
#define OUT "A.OUT"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    if(fopen(IN, "r")){
        freopen(IN, "r", stdin);
        freopen(OUT, "w", stdout);
    }
    int n, k; cin >> n >> k;
    vector<int> hei(n);
    for(int &i : hei) cin >> i;
    int cnt = 0;
    if(hei[0] > k){
        cnt ++;
        hei[0] = k;
    }
    for(int i = 0; i < n; i++){
        hei[i] = k*(i + 1) - hei[i];
    }
    vector<int> min_j(n + 1, 0);
    int mx = 0;
    auto bs = [&](int u) -> int{
        int l = 0, r = mx, ans = 0;
        while(l <= r){
            int m = (l + r)/2;
            if(min_j[m] <= u){
                ans = m;
                l = m + 1;
            }
            else r = m - 1;
        }
        return ans;
    };
    for(int i = 0; i < n; i++){
        int j = bs(hei[i]);
        mx = max(mx, j + 1);
        min_j[j + 1] = hei[i];
    }
    cout << n - (mx - cnt);
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
