Submission #810539

#TimeUsernameProblemLanguageResultExecution timeMemory
810539tlnk07Po (COCI21_po)C++17
70 / 70
29 ms1456 KiB
#include<bits/stdc++.h> using namespace std; long long n, cnt = 0, x; stack<int> sta; int main() { cin >> n; for(int i = 1; i <= n; ++i) { cin >> x; while(!sta.empty() && sta.top() > x) sta.pop(); if(!sta.empty() && sta.top() == x || !x) continue; sta.push(x); ++cnt; } cout << cnt; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:14:19: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   14 |   if(!sta.empty() && sta.top() == x || !x) continue;
      |      ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...