Submission #636421

#TimeUsernameProblemLanguageResultExecution timeMemory
636421TUNGDUONGWILLWINVOI2023Rabbit Carrot (LMIO19_triusis)C++14
100 / 100
36 ms4428 KiB
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; const int NAXM = 2e5 + 5; int n, m, a[NAXM]; int main() { // Coding scanf("%d%d", &n, &m); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } vector<int> b; for (int i = 0; i < n; ++i) { if (m * (i + 1) >= a[i]) { b.push_back(m * (i + 1) - a[i]); } } vector<int> dp; int L = int(b.size()); for (int i = 0; i < L; ++i) { int l = lower_bound(dp.begin(), dp.end(), b[i] + 1) - dp.begin(); if (l < int(dp.size())) { dp[l] = b[i]; } else { dp.push_back(b[i]); } } printf("%d\n", n - int(dp.size())); return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
triusis.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     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...