Submission #610983

#TimeUsernameProblemLanguageResultExecution timeMemory
610983lucas_joel_hanRabbit Carrot (LMIO19_triusis)C++14
100 / 100
30 ms3152 KiB
#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 + 1) >= a[i]) b.push_back(M * (i + 1) - 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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...