# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
169162 |
2019-12-18T18:26:02 Z |
tselmegkh |
Money (IZhO17_money) |
C++14 |
|
2 ms |
376 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
int ans = 1;
for(int i = 0; i < n; i++){
cin >> a[i];
}
int j = 1;
multiset<int> ms;
while(a[j] >= a[j - 1] && j < n){
ms.insert(a[j]);
j++;
}
int cnt = 0, bound = 0;
while(j < n){
if(cnt == 0){
ans++;
auto it = ms.upper_bound(a[j]);
if(it != ms.end()){
bound = *it;
}else{
bound = 1e9;
}
ms.insert(a[j]);
cnt++;
j++;
}else{
if(a[j] < a[j - 1]){
cnt = 0;
continue;
}else{
if(a[j] <= bound){
ms.insert(a[j]);
cnt++;
j++;
}else{
cnt = 0;
}
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |