답안 #610981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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++) {
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -