Submission #846946

# Submission time Handle Problem Language Result Execution time Memory
846946 2023-09-08T17:55:07 Z SUNWOOOOOOOO Financial Report (JOI21_financial) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int mxN = 7005;
int n, d, A[mxN], dp1[mxN][mxN], dp2[mxN][mxN]; // len, dist
vector <int> va;

int main()
{
    memset(dp1, -1, sizeof dp1);
    scanf("%d %d", &n, &d);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
        va.push_back(A[i]);
    }
    sort(va.begin(), va.end());
    va.erase(unique(va.begin(), va.end()), va.end());
    for (int i = 1; i <= n; i++) A[i] = lower_bound(va.begin(), va.end(), A[i]) - va.begin() + 1;

    // int ans = 0;
    // for (int i = 1; i <= n; i++){
    //     dp1[i][A[i]] = 1, dp2[i][A[i]] = 1;
    //     if (dp1[i - 1][A[i]] != -1 && dp2[i - 1][A[i]] <= d) dp1[i][A[i]] = dp1[i - 1][A[i]];
    //     for (int j = 1; j < A[i]; j++){
    //         if (dp1[i - 1][j] == -1 || dp2[i - 1][j] > d) continue;
    //         dp1[i][j] = dp1[i - 1][j];
    //         dp2[i][j] = dp2[i - 1][j] + 1;
    //         dp1[i][A[i]] = max(dp1[i][A[i]], dp1[i - 1][j] + 1);
    //     }
    //     for (int j = A[i] + 1; j <= n; j++){
    //         if (dp1[i - 1][j] == -1) continue;
    //         dp1[i][j] = dp1[i - 1][j];
    //         dp2[i][j] = 1;
    //     }
    //     for (int j = 1; j <= n; j++) ans = max(ans, dp1[i][j]);
    // }

    printf("%d\n", ans);

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:37:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     printf("%d\n", ans);
      |                    ^~~
      |                    abs
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", &A[i]);
      |         ~~~~~^~~~~~~~~~~~~