답안 #999572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
999572 2024-06-15T20:12:13 Z vjudge1 Rabbit Carrot (LMIO19_triusis) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define inf (int)1e15

int binsearch(int val, vector<int>& vec){
    int l = 0, r = (int)vec.size()-1, mid;
    while(l < r){
        mid = (l + r + 1)/2;
        if(vec[mid] <= val){
            l = mid;
        }else{
            r = mid-1;
        }
    }
    if(l != (int)vec.size() - 1){
        l++;
    }
    return l;
}

void solve(){
    int n, m; cin >> n >> m;
    vector<int> vals(n);
    for(int i = 0; i < n; i++){
        cin >> vals[i];
        vals[i] -= (m * i);
    }
    reverse(vals.begin(), vals.end());
    vector<int> v;
    //v sorted in increasing size
    for(int i = 0; i < n; i++){
        if((int)v.size() == 0){
            v.push_back(vals[i]);
            continue;
        }
        int ind = binsearch(vals[i], v);
        if(v[ind] <= vals[i]){
            v.push_back(vals[i]);
        }else{
            v[ind] = vals[i];
        }
        //cout << i << ", " << ind << "\n";
    }
    if(v[0] > m){
        cout << n << "\n";
        return;
    }
    cout << n - (int)v.size() << "\n";
}

signed main(){
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("txt.in", "r", stdin); freopen("txt.out", "w", stdout);
    //int t; cin >> t; while(t--)
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -