# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
429359 |
2021-06-15T21:40:42 Z |
jovan_b |
Money (IZhO17_money) |
C++17 |
|
1 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MAXN = 1000000;
int bit[MAXN+5];
multiset <int> q;
int a[MAXN+5];
bool ima(int l, int r){
auto x = q.lower_bound(l);
return x != q.end() && *x <= r;
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n;
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i];
for(int i=1; i<n; i++) q.insert(a[i]);
int splits = 0;
int psl = a[n];
for(int i=n-1; i>=1; i--){
if(a[i] > a[i+1]){
psl = a[i];
splits++;
}
else{
if(ima(a[i]+1, psl-1)){
splits++;
psl = a[i] - 1;
}
}
q.erase(q.find(a[i]));
}
cout << splits + 1 << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |