fork download
  1.  
  2. stack<int> stack;
  3. for (int i = 0 ; i < N; ++i) {
  4. int currentElement = A[i];
  5.  
  6. // skip current iteration if currentElement is not less than 0
  7. while (!stack.empty() && stack.top() < currentElement) {
  8.  
  9. answer = minimum(answer, stack.top() * currentElement);
  10. stack.pop();
  11. }
  12. stack.push(currentElement);
  13. }
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:1: error: ‘stack’ does not name a type
 stack<int> stack;
 ^~~~~
prog.cpp:3:1: error: expected unqualified-id before ‘for’
 for (int i = 0 ; i < N; ++i) {
 ^~~
prog.cpp:3:18: error: ‘i’ does not name a type
 for (int i = 0 ; i < N; ++i) {
                  ^
prog.cpp:3:25: error: expected unqualified-id before ‘++’ token
 for (int i = 0 ; i < N; ++i) {
                         ^~
stdout
Standard output is empty