# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
229869 | pedroslrey | Money (IZhO17_money) | C++14 | 5 ms | 256 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.
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using lli = long long int;
#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define fi first
#define se second
#define all(xs) xs.begin(), xs.end()
const int INF = 1e9;
vector<int> xs;
vector<int> ys;
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int x;
scanf("%d", &x);
xs.pb(x);
}
ys.push_back(xs[0]);
for (int i = 1; i < n; ++i)
if (xs[i] != xs[i-1])
ys.push_back(xs[i]);
int m = (int)ys.size();
set<int> s;
s.insert(INF);
int total = 0;
int k = 0;
for (int i = 0; i < m-1; ++i) {
if ((ys[i] > ys[i+1]) || (ys[i] < ys[i+1] && *s.lower_bound(ys[i]-k+1) < ys[i+1])){
k = 0;
++total;
}
else k = 1;
s.insert(ys[i]);
}
printf("%d\n", total);
}
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... |