제출 #749265

#제출 시각아이디문제언어결과실행 시간메모리
749265PanosPaskRabbit Carrot (LMIO19_triusis)C++14
100 / 100
40 ms4572 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
vector<int> a;
vector<ll> d;

int main(void)
{
    scanf("%d %d", &n, &m);

    a.resize(n);
    d.assign(n+1, INT_MIN);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    d[0] = INT_MAX;
    for (int i = 0; i < n; i++) {
        ll curval = a[i] - m * (i + 1);
        if (curval > 0)
            continue;
        int l = 0;
        int r = n + 1;
        while (r > l + 1) {
            int mid = (l + r) / 2;
            if (d[mid] >= curval)
                l = mid;
            else
                r = mid;
        }

        d[l+1] = curval;
    }

    int ans = 0;
    for (int i = 0; i < n + 1; i++)
        if (d[i] != INT_MIN)
            ans = i;

    printf("%d\n", n - ans);
    return 0;
}

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

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