제출 #1329280

#제출 시각아이디문제언어결과실행 시간메모리
1329280floPo (COCI21_po)C++20
70 / 70
7 ms644 KiB
#include <bits/stdc++.h>
#define task "xepgach"
#define ll long long
#define multitest 0
using namespace std;

stack<int> st;

void flo(int ID) {
	int n, ans = 0; cin >> n;
	
	for (int x = 1; x <= n; x++) {
		int v; cin >> v;
		
		if (!v) {
			while (!st.empty()) st.pop();
		}
		else {
			while (!st.empty() && st.top() > v) st.pop();
			
			if (st.empty() || st.top() != v) ans++, st.push(v);
		}
	}
	
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}

	int TCS = 1, ID = 1;

	if (multitest) {
		cin >> TCS;
	}

	while (TCS--) flo(ID++);

	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:33:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |                 freopen(task".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:34:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |                 freopen(task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...