답안 #1025344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025344 2024-07-16T22:26:02 Z eysbutno Global Warming (CEOI18_glo) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = array<int, 2>;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int &i : a) {
        cin >> i;
    }
    vector<int> dp, pf(n);
    int res = 0;
    for (int i = 0; i < n; i++) {
        int ind = lower_bound(all(dp), a[i]) - begin(dp);
        if (ind == sz(dp)) dp.push_back(0);
        dp[ind] = a[i], pf[i] = j + 1;
        res = max(res, pf[i]);
    }
    dp.clear();
    for (int i = n - 1; i >= 0; i--) {
        int ind = lower_bound(all(dp), x - a[i]) - begin(dp);
        res = max(res, pf[i] + ind);
        ind = lower_bound(all(dp), -a[i]) - begin(dp);
        if (ind == sz(dp)) dp.push_back(0);
        dp[ind] = -a[i];
    }
    cout << res << "\n";
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:21:33: error: 'j' was not declared in this scope
   21 |         dp[ind] = a[i], pf[i] = j + 1;
      |                                 ^