# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
533260 | devariaota | Money (IZhO17_money) | C++17 | 837 ms | 61868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >
int main() {
nyahalo
long long n;
cin >> n;
long long ans = 0, a[n+1], pv, ab, l, r, val;
set<long long> st;
for (long long i=1; i<=n; i++) {
cin >> a[i];
}
l = 1;
while (l<=n) {
ans++;
r = l+1;
if (l == 1) {
val = 1e9;
} else {
auto it = st.upper_bound(a[l]);
if (it == st.end()) {
val = 1e9;
} else {
val = *it;
}
}
st.insert(a[l]);
while (r<=n) {
if (a[r]>val || a[r]<a[r-1]) {
break;
}
st.insert(a[r]);
r++;
}
l = r;
}
cout << ans << "\n";
otsumiko
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |