Submission #677861

#TimeUsernameProblemLanguageResultExecution timeMemory
677861MherMoney (IZhO17_money)C++14
9 / 100
1 ms212 KiB
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> #include <queue> using namespace std; const int N = 1000003, mod = 1e9 + 7; int n; int a[N]; void solve() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int ans = 0; multiset<int> st; multiset<int>::iterator p = st.insert(0), c; for (int i = 1; i <= n; i++) { if (a[i] < a[i - 1]) { ans++; c = st.insert(a[i]); p = c; continue; } if (a[i] == a[i - 1]) { st.insert(a[i]); p++; continue; } c = st.insert(a[i]); c = st.lower_bound(a[i]); if (++p != c) { ans++; p = c; } } cout << ans + 1 << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) solve(); return 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...