제출 #710095

#제출 시각아이디문제언어결과실행 시간메모리
710095hpesojMoney (IZhO17_money)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h>
#define int long long
#define pi pair <int, int>
#define ppi pair <pi, int>
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
const int inf = 1000000000;
int n, a[1000005], prefmax[1000005], prefmin[1000005];
signed main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	prefmin[0] = inf;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		prefmax[i] = max(prefmax[i-1], a[i]);
		prefmin[i] = min(prefmin[i-1], a[i]);
	}
	int ans = 1;
	int l = 1;
	for(int i = 2; i <= n; i++){
		if(ans == 1 and a[i] < a[i-1]){
			ans++;
			//for(int j = l; j < i; j++) cout << a[j] << ' ';
			//cout << '\n';
			//l = i;
		}
		else if(ans != 1 and (a[i] < a[i-1] or a[i] < prefmin[i-1] or a[i] > prefmax[i-1])){
			ans++;
			//for(int j = l; j < i; j++) cout << a[j] << ' ';
			//cout << '\n';
			//l = i;
		}
	}
	cout << ans;
}

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

money.cpp: In function 'int main()':
money.cpp:22:6: warning: unused variable 'l' [-Wunused-variable]
   22 |  int l = 1;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...