제출 #92817

#제출 시각아이디문제언어결과실행 시간메모리
92817I_am_muslimMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define in freopen("input.txt", "r" ,stdin) #define out freopen("output.txt", "w" , stdout) #define ll long long #define inf 200005 #define fr first #define sc second #define pb push_back #define p_b pop_back #define mp make_pair using namespace std; int n; int a[1000005]; int main (){ //in;out; ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i]; } int maxx = 0; int minn = 1e6+10; a[0] = 0; minn = a[1]; int ind = 1; for (int i = 1; i <=n; i++){ if (a[i] >= a[i-1]) { ind = i; maxx = a[i]; } else break; } minn = a[1]; int cnt = 1; for (int i = ind+1 ; i <= n; i++) { if (a[i] >= maxx){ while (a[i] >= maxx){ maxx = a[i]; i++; } cnt++; continue; } if (a[i]>= minn){ while (a[i] <= maxx and a[i] <= a[i+1]){ i++; } cnt++; continue; } if (a[i] < minn){ int t = a[i]; while (a[i] <= minn and a[i] <= a[i+1]){ i++; } minn = t; cnt++; } } cout << cnt ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...