Submission #92813

#TimeUsernameProblemLanguageResultExecution timeMemory
92813I_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; } bool flag = 0, flag1 = 0; int cnt = 1; for (int i = ind+1 ; i <= n; i++) { if (a[i] >= maxx){ while (a[i] >= maxx){ maxx = a[i]; i++; } cnt++; } if (i > n) break; if (a[i]>= minn){ while (a[i] <= maxx and a[i] <= a[i+1]){ i++; } if (a[i] <= maxx)i++; cnt++; } if (i > n) break; if (a[i] < minn){ int t = a[i]; while (a[i] <= minn and a[i] <= a[i+1]){ i++; } minn = t; if (a[i] <= minn) i++; cnt++; } } cout << cnt ; }

Compilation message (stderr)

money.cpp: In function 'int main()':
money.cpp:34:6: warning: unused variable 'flag' [-Wunused-variable]
 bool flag = 0, flag1 = 0;
      ^~~~
money.cpp:34:16: warning: unused variable 'flag1' [-Wunused-variable]
 bool flag = 0, flag1 = 0;
                ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...