# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386235 | patrikpavic2 | Money (IZhO17_money) | C++17 | 1 ms | 364 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 <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#define X first
#define Y second
#define PB push_back
using namespace std;
const int N = 1e6 + 500;
int A[N], n, prv[N], nxt[N], sol;
multiset < int > S;
int main(){
scanf("%d", &n);
for(int i = 0;i < n;i++){
scanf("%d", A + i);
S.insert(A[i]);
}
nxt[0] = 0, prv[n + 1] = n;
for(int i = 1;i <= n;i++){
prv[i] = i - 1;
nxt[i] = i + 1;
}
for(int i = n - 1;i >= 0;i--){
S.erase(S.lower_bound(A[i]));
while(i > 0 && A[i] >= *S.begin() && (A[i] == A[i - 1] || A[i - 1] == *(--S.lower_bound(A[i])))){
i--; S.erase(S.lower_bound(A[i]));
}
sol++;
}
printf("%d\n", sol);
}
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... |