제출 #1086321

#제출 시각아이디문제언어결과실행 시간메모리
1086321firegirlwaterboyRabbit Carrot (LMIO19_triusis)C++14
100 / 100
19 ms5336 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 : poss) {
        int pos = upper_bound(ans.begin(), ans.end(), i) - ans.begin();
        if (pos == ans.size()) {
            ans.push_back(i);
        } else {
            ans[pos] = i;
        }
    }
    cout << n - ans.size() << "\n";
}

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

컴파일 시 표준 에러 (stderr) 메시지

triusis.cpp: In function 'void solve()':
triusis.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if (pos == 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...