Submission #1086320

# Submission time Handle Problem Language Result Execution time Memory
1086320 2024-09-10T07:20:53 Z firegirlwaterboy Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 348 KB
#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

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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -