제출 #1025344

#제출 시각아이디문제언어결과실행 시간메모리
1025344eysbutnoGlobal Warming (CEOI18_glo)C++17
컴파일 에러
0 ms0 KiB
#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";
}

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

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;
      |                                 ^