Submission #811194

#TimeUsernameProblemLanguageResultExecution timeMemory
811194Tunglam07Po (COCI21_po)C++17
70 / 70
41 ms1340 KiB
#include<bits/stdc++.h> using namespace std; int main() { stack<int> st; long long n, cnt = 0; cin >> n; for(int i = 0; i < n; i++) { int val; cin >> val; while(!st.empty() && st.top() > val) { st.pop(); } if(!st.empty() && st.top() == val || !val) { continue; } st.push(val); cnt++; } cout << cnt; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:17:18: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   17 |   if(!st.empty() && st.top() == val || !val)
      |      ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...