Submission #385763

#TimeUsernameProblemLanguageResultExecution timeMemory
385763SansPapyrus683Global Warming (CEOI18_glo)C++17
28 / 100
2088 ms1132 KiB
#include <iostream> #include <vector> #include <algorithm> using std::cout; using std::endl; using std::vector; int find_lis(const vector<int>& a) { vector<int> dp; for (int i : a) { int pos = lower_bound(dp.begin(), dp.end(), i) - dp.begin(); if (pos == dp.size()) // we can have a new, longer increasing subsequence! dp.push_back(i); else // oh ok, at least we can make the ending element smaller dp[pos] = i; } return dp.size(); } int main() { int temp_num; int max_cheating; std::cin >> temp_num >> max_cheating; vector<int> temps(temp_num); for (int t = 0; t < temp_num; t++) { std::cin >> temps[t]; } int longest = 0; for (int i = temp_num - 1; i >= 0; i--) { temps[i] += max_cheating; longest = std::max(longest, find_lis(temps)); } cout << longest << endl; }

Compilation message (stderr)

glo.cpp: In function 'int find_lis(const std::vector<int>&)':
glo.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 == dp.size())  // we can have a new, longer increasing subsequence!
      |       ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...