Submission #676256

#TimeUsernameProblemLanguageResultExecution timeMemory
676256omikron123Rabbit Carrot (LMIO19_triusis)C++14
100 / 100
29 ms3080 KiB
// https://oj.uz/problem/view/LMIO19_triusis #include <cstdio> #include <algorithm> #include <functional> #include <vector> #include <cstring> using namespace std; typedef long long ll; /* 5 400 300 700 200 1000 500 dp[i][j]:到达第i个柱子,调整j个柱子时,能达到的最大的高度。 Slack: - 100 0 900 -400 900: a[i]+x, a[i]-x,找到最短的区间,使得和大于0? Maximize # of poles that do not change: - Find a subsequence where no gap is larger than d*M - M*i - a[i],问题就变成了在这个中间寻找LIS */ int n, m; int b[200005]; int main() { scanf("%d %d", &n, &m); vector<int> dp; // LIS dp.push_back(0); for (int i = 1; i <= n; i++) { int a; scanf("%d", &a); int b = m*i - a; if (b < 0) continue; auto it = upper_bound(dp.begin(), dp.end(), b); if (it == dp.end()) dp.push_back(b); else *it = b; } printf("%d", n-dp.size()+1); return 0; }

Compilation message (stderr)

triusis.cpp: In function 'int main()':
triusis.cpp:41:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   41 |     printf("%d", n-dp.size()+1);
      |             ~^   ~~~~~~~~~~~~~
      |              |              |
      |              int            std::vector<int>::size_type {aka long unsigned int}
      |             %ld
triusis.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
triusis.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...