제출 #1335415

#제출 시각아이디문제언어결과실행 시간메모리
1335415taropolyRabbit Carrot (LMIO19_triusis)C++20
0 / 100
1 ms344 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define TEST
const int INF = 2e9;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N{}, M{};
    cin >> N >> M;
    vector<int> poles(N);
    for (int i = 0; i < N; i++) {
        cin >> poles[i];
        poles[i]=(M*i+i)-poles[i];
    }
    //longest increasing subsequence

    vector<int> dp(N+1,INF);  // d_i(j)
    dp[0] = -INF;
    for (int i = 0; i < N; i++) {
        int pos =upper_bound(dp.begin(), dp.end(), poles[i]) - dp.begin();
        if (dp[pos-1] < poles[i]) {
            dp[pos]=poles[i];
        }
    }
    int max_len{0};
    for (int i = 1; i <= N; i++) {
        if (dp[i]!=INF) {
            max_len=i;
        }
        else {
            break;
        }
    }
    cout << max_len << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...