Submission #610981

# Submission time Handle Problem Language Result Execution time Memory
610981 2022-07-28T21:53:53 Z lucas_joel_han Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> a(N), b;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (M * i >= a[i])
            b.push_back(M * i - a[i]);
    }
    vector<int> dp(b.size() + 1, INT_MAX);
    dp[0] = INT_MIN;
    for (int i = 0; i < b.size(); i++) {
        int x = b[i];
        int j = upper_bound(dp.begin(), dp.end(), x) - dp.begin();
        if (dp[j - 1] <= x && x <= dp[j]) {
            dp[j] = x;
        }
    }
    int sol = 0;
    for (int i = 0; i <= b.size(); i++) {
        if (dp[i] != INT_MAX) {
            sol = i;
        }
    }
    cout << (N - sol) << '\n';
}

Compilation message

triusis.cpp: In function 'int main()':
triusis.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < b.size(); i++) {
      |                     ~~^~~~~~~~~~
triusis.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 0; i <= b.size(); i++) {
      |                     ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 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 1 ms 320 KB Output is correct
2 Correct 1 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 1 ms 320 KB Output is correct
2 Correct 1 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 1 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -