Submission #1096680

#TimeUsernameProblemLanguageResultExecution timeMemory
1096680ezGeometryRabbit Carrot (LMIO19_triusis)C++14
100 / 100
60 ms4296 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> bunnies(n); for (int i = 0; i < n; i++) { int x; cin >> x; bunnies[i] = i * m + m - x; } vector<int> dp; for (int i = 0; i < n; i++) { if (bunnies[i] < 0) { continue; } int pos = upper_bound(dp.begin(), dp.end(), bunnies[i]) - dp.begin(); if (pos == dp.size()) { dp.push_back(bunnies[i]); } else { dp[pos] = bunnies[i]; } } cout << n - dp.size() << endl; }

Compilation message (stderr)

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