제출 #341857

#제출 시각아이디문제언어결과실행 시간메모리
341857boykutHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define work_with_io ios::sync_with_stdio(0);cin.tie(0); //#define int long long signed main() { std::work_with_io; int q = 1; //cin >> q; while (q--) { int n, m; cin >> n >> m; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int mna = *min_element(a, a + n); int dp[n]; dp[0] = 1; for (int i = 1; i < n; i++) { if (a[i] >= a[i - 1]) dp[i] = dp[i - 1] + 1; else dp[i] = 1; } for (int tmp = m; tmp--;) { int l, r, k; cin >> l >> r >> k; l--;r--; if (k < mna) { if (r-l+1 <= dp[r]) cout << "1\n"; else cout << "0\n"; } else { int ans = 1; set <int> st; set <int>::iterator it; for (int left = l; left <= r; left++) { //int Bg = a[left], Lt = k-a[left]; // Lt = k-Bg if (left == l) { Bg = a[left]; } else { if (a[left] < Bg && a[left] > k - Bg) ans = 0; Bg = max(Bg, a[left]); } } cout << ans << '\n'; } } } return 0; }

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

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:45:7: error: 'Bg' was not declared in this scope
   45 |       Bg = a[left];
      |       ^~
sortbooks.cpp:47:21: error: 'Bg' was not declared in this scope
   47 |       if (a[left] < Bg && a[left] > k - Bg)
      |                     ^~
sortbooks.cpp:49:7: error: 'Bg' was not declared in this scope
   49 |       Bg = max(Bg, a[left]);
      |       ^~