Problem rollercoaster
User Hijackedsoul
Submission Time 2025-06-30 10:21:37
Score 0
Max Time N/A
Max Memory N/A

Compile Error

rollercoaster.cpp: In function ‘int main()’:
rollercoaster.cpp:11:8: error: ‘k’ was not declared in this scope
11 | if(i<k) st.insert(arr[i]);
| ^
rollercoaster.cpp:15:12: error: ‘k’ was not declared in this scope
15 | for(int i=k; i<n; i++){
| ^
rollercoaster.cpp:18:26: error: invalid use of non-static member function ‘std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::end() const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<int>]’
18 | std::cout << *(prev(st.end, 1)) - *st.begin() <<" ";
| ~~~^~~
In file included from /usr/include/c++/9/set:61,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
from rollercoaster.cpp:1:
/usr/include/c++/9/bits/stl_set.h