Submission #811194

# Submission time Handle Problem Language Result Execution time Memory
811194 2023-08-07T02:16:21 Z Tunglam07 Po (COCI21_po) C++17
70 / 70
41 ms 1340 KB
#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

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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 7 ms 416 KB Output is correct
5 Correct 10 ms 436 KB Output is correct
6 Correct 41 ms 1340 KB Output is correct
7 Correct 29 ms 1164 KB Output is correct