Submission #551159

#TimeUsernameProblemLanguageResultExecution timeMemory
551159tht2005Financial Report (JOI21_financial)C++17
48 / 100
4033 ms6724 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 300005;
int n, d, m, a[N], v[N], f[N];

int main() {
    scanf("%d %d", &n, &d);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        v[i] = a[i];
    }
    sort(v, v + n);
    m = unique(v, v + n) - v;
    for(int i = 0; i < n; ++i) {
        a[i] = lower_bound(v, v + m, a[i]) - v;
    }
    for(int i = 0; i < n; ++i) {
        f[i] = 1;
        for(int j = i, cnt = 0; j--; ) {
            if(a[j] < a[i]) {
                f[i] = max(f[i], f[j] + 1);
                cnt = 0;
            }
            else if((++cnt) == d) {
                break;
            }
        }
    }
    printf("%d", *max_element(f, f + n));
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d %d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...