제출 #1128135

#제출 시각아이디문제언어결과실행 시간메모리
1128135micro7Rabbit Carrot (LMIO19_triusis)C++17
63 / 100
1093 ms2196 KiB
#include <algorithm>
#include <cstdio>
#include <functional>
#include <map>
using namespace std;

constexpr int MAXN = 2e5;
int n, m, a[MAXN + 1];

int dp[MAXN + 1];
map<int, int, greater<>> s;

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }

  s[0] = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i] = -1;
    for (auto [val, j] : s) {
      if (a[i] - i * m > val) {
        break;
      }
      if (dp[j] != -1) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
    s[a[i] - i * m] = i;
  }
  printf("%d", n - *max_element(dp, dp + n + 1));

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

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