제출 #811194

#제출 시각아이디문제언어결과실행 시간메모리
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;
}

컴파일 시 표준 에러 (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...