Submission #893858

#TimeUsernameProblemLanguageResultExecution timeMemory
893858agawronRabbit Carrot (LMIO19_triusis)C++14
100 / 100
22 ms4760 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back constexpr int MAX_N = 2e5 + 5; constexpr int INF = 1e9; int n, m; int a[MAX_N]; int b[MAX_N]; vector <int> seq; int LIS(){ 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(); } int main(){ scanf("%d %d", &n, &m); for(int i = 1; i <= n; i++){ scanf("%d", &a[i]); } int cnt = 0; for(int i = 1; i <= n; i++){ b[i] = m * i - a[i]; if(b[i] >= 0) seq.pb(b[i]); } cnt = n - LIS(); printf("%d\n", cnt); return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int LIS()':
triusis.cpp:24:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if (pos == min_endings.size()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~
triusis.cpp: In function 'int main()':
triusis.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
triusis.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d", &a[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...