Submission #1086320

#TimeUsernameProblemLanguageResultExecution timeMemory
1086320firegirlwaterboyRabbit Carrot (LMIO19_triusis)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> poles(n);
    for (int &p : poles) {
        cin >> p;
    }
    vector<int> poss;
    for (int i = 1; i <= n; i++) {
        if (i * k >= poles[i - 1]) poss.push_back(i * k - poles[i - 1]);
    }
    vector<int> ans;
    for (int i = 0; i < n; i++) {
        int v = poss[i];
        int idx = upper_bound(ans.begin(), ans.end(), v) - ans.begin();
        if (idx == ans.size()) {
            ans.push_back(v);
        } else {
            ans[idx] = v;
        }
    }
    cout << n - ans.size() << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Compilation message (stderr)

triusis.cpp: In function 'void solve()':
triusis.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if (idx == ans.size()) {
      |             ~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...