답안 #810539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810539 2023-08-06T10:56:57 Z tlnk07 Po (COCI21_po) C++17
70 / 70
29 ms 1456 KB
#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

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;
      |      ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 8 ms 316 KB Output is correct
5 Correct 10 ms 492 KB Output is correct
6 Correct 29 ms 1456 KB Output is correct
7 Correct 29 ms 1260 KB Output is correct