Submission #385219

#TimeUsernameProblemLanguageResultExecution timeMemory
385219SansPapyrus683Rabbit Carrot (LMIO19_triusis)C++17
100 / 100
99 ms5348 KiB
#include <iostream> #include <vector> #include <algorithm> using std::cout; using std::endl; using std::vector; int longest_inc_subseq(const vector<int>& seq) { vector<int> min_endings; for (int i : seq) { int pos = std::upper_bound(min_endings.begin(), min_endings.end(), i) - min_endings.begin(); if (pos == min_endings.size()) { min_endings.push_back(i); } else { min_endings[pos] = i; } } return min_endings.size(); } /** * https://oj.uz/problem/view/LMIO19_triusis * 5 400 * 300 * 700 * 200 * 1000 * 500 should output 1 */ int main() { int pole_num; int jump_height; std::cin >> pole_num >> jump_height; vector<int> poles(pole_num); for (int p = 0; p < pole_num; p++) { std::cin >> poles[p]; } vector<int> poss_unchanged; for (int i = 1; i <= pole_num; i++) { if (i * jump_height >= poles[i - 1]) { poss_unchanged.push_back(i * jump_height - poles[i - 1]); } } cout << pole_num - longest_inc_subseq(poss_unchanged) << endl; }

Compilation message (stderr)

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