# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
377072 |
2021-03-12T23:20:57 Z |
ijxjdjd |
Money (IZhO17_money) |
C++14 |
|
1 ms |
364 KB |
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
multiset<int> lft;
const int MAXN = (int)(1e6);
int arr[MAXN + 5];
int cnt[MAXN+5];
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int N;
// N = (int)(1e6);
cin >> N;
FR(i, N) {
cin >> arr[i];
// arr[i] = N-i;
// cnt[arr[i]]++;
lft.insert(arr[i]);
}
int lst = arr[N-1];
int ans = 1;
bool ori = true;
for (int i = N-2; i >= 0; i--) {
lft.erase(lft.find(arr[i+1]));
cnt[arr[i+1]]--;
if (lst == arr[i]) {
}
else {
auto it = lft.lower_bound(lst);
if (it != lft.begin() && (*prev(it)) == arr[i]) {
if (cnt[lst]) {
if (ori) {
ori = false;
}
else {
ans++;
ori = true;
}
}
else {
ori = false;
}
}
else {
ans++;
ori = true;
}
}
lst = arr[i];
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |