# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966543 | yellowtoad | Money (IZhO17_money) | C++17 | 853 ms | 58428 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 <iostream>
#include <set>
#include <vector>
using namespace std;
int n, a[1000010], cnt;
multiset<int> bst;
multiset<int>::iterator iter;
vector<int> tmp;
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
tmp.push_back(0);
for (int i = 1; i <= n; i++) {
if (a[i-1] > a[i]) {
cnt++;
for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]);
tmp.clear();
} else {
iter = bst.upper_bound(tmp[0]);
if ((iter != bst.end()) && (*iter < a[i])) {
cnt++;
for (int j = 0; j < tmp.size(); j++) bst.insert(tmp[j]);
tmp.clear();
}
}
tmp.push_back(a[i]);
}
cout << cnt+1 << endl;
}
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... |