제출 #1331837

#제출 시각아이디문제언어결과실행 시간메모리
1331837kawhiet3단 점프 (JOI19_jumps)C++20
컴파일 에러
0 ms0 KiB
a#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> stk;
    vector<array<int, 2>> pos;
    for (int i = 0; i < n; i++) {
        while (!stk.empty() && a[stk.back()] < a[i]) {
            stk.pop_back();
        }
        if (!stk.empty()) {
            pos.push_back({stk.back(), i});
        }
        stk.push_back(i);
    }
    vector<int> s(n + 1);
    for (int i = n - 1; i >= 0; i--) {
        s[i] = max(s[i + 1], a[i]);
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--; r--;
        int ans = 0;
        for (auto [i, j] : pos) {
            int k = 2 * j - i;
            if (k > j && k < n && l <= i && k <= r) {
                ans = max(ans, a[i] + a[j] + s[k]);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

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

jumps.cpp:1:2: error: stray '#' in program
    1 | a#include <bits/stdc++.h>
      |  ^
jumps.cpp:1:1: error: 'a' does not name a type
    1 | a#include <bits/stdc++.h>
      | ^
jumps.cpp: In function 'int main()':
jumps.cpp:5:5: error: 'ios' has not been declared
    5 |     ios::sync_with_stdio(false);
      |     ^~~
jumps.cpp:6:5: error: 'cin' was not declared in this scope
    6 |     cin.tie(nullptr);
      |     ^~~
jumps.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> a(n);
      |     ^~~~~~
jumps.cpp:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> a(n);
      |            ^~~
jumps.cpp:11:16: error: 'a' was not declared in this scope
   11 |         cin >> a[i];
      |                ^
jumps.cpp:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> stk;
      |            ^~~
jumps.cpp:14:12: error: 'array' was not declared in this scope
   14 |     vector<array<int, 2>> pos;
      |            ^~~~~
jumps.cpp:14:18: error: expected primary-expression before 'int'
   14 |     vector<array<int, 2>> pos;
      |                  ^~~
jumps.cpp:16:17: error: 'stk' was not declared in this scope; did you mean 'std'?
   16 |         while (!stk.empty() && a[stk.back()] < a[i]) {
      |                 ^~~
      |                 std
jumps.cpp:16:32: error: 'a' was not declared in this scope
   16 |         while (!stk.empty() && a[stk.back()] < a[i]) {
      |                                ^
jumps.cpp:19:14: error: 'stk' was not declared in this scope; did you mean 'std'?
   19 |         if (!stk.empty()) {
      |              ^~~
      |              std
jumps.cpp:20:13: error: 'pos' was not declared in this scope
   20 |             pos.push_back({stk.back(), i});
      |             ^~~
jumps.cpp:22:9: error: 'stk' was not declared in this scope; did you mean 'std'?
   22 |         stk.push_back(i);
      |         ^~~
      |         std
jumps.cpp:24:12: error: expected primary-expression before 'int'
   24 |     vector<int> s(n + 1);
      |            ^~~
jumps.cpp:26:9: error: 's' was not declared in this scope
   26 |         s[i] = max(s[i + 1], a[i]);
      |         ^
jumps.cpp:26:30: error: 'a' was not declared in this scope
   26 |         s[i] = max(s[i + 1], a[i]);
      |                              ^
jumps.cpp:26:16: error: 'max' was not declared in this scope
   26 |         s[i] = max(s[i + 1], a[i]);
      |                ^~~
jumps.cpp:35:28: error: 'pos' was not declared in this scope
   35 |         for (auto [i, j] : pos) {
      |                            ^~~
jumps.cpp:38:32: error: 'a' was not declared in this scope
   38 |                 ans = max(ans, a[i] + a[j] + s[k]);
      |                                ^
jumps.cpp:38:46: error: 's' was not declared in this scope
   38 |                 ans = max(ans, a[i] + a[j] + s[k]);
      |                                              ^
jumps.cpp:38:23: error: 'max' was not declared in this scope
   38 |                 ans = max(ans, a[i] + a[j] + s[k]);
      |                       ^~~
jumps.cpp:41:9: error: 'cout' was not declared in this scope
   41 |         cout << ans << '\n';
      |         ^~~~