Submission #533590

#TimeUsernameProblemLanguageResultExecution timeMemory
533590devariaotaMoney (IZhO17_money)C++17
100 / 100
1184 ms51316 KiB
#include <bits/stdc++.h> using namespace std; int arr[1000005]; const int inf = 1e9 + 7; int main(){ int n; cin >> n; for(int i = 0; i < n; i++) cin >> arr[i]; set < int > st; st.insert(inf); int ans = 0; for(int i = 0; i < n; ){ ans++; int j = i + 1; int x = *st.upper_bound(arr[i]); st.insert(arr[i]); while (j < n && arr[j - 1] <= arr[j] && arr[j] <= x){ st.insert(arr[j]); j++; } i = j; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...