# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
494948 |
2021-12-17T17:15:06 Z |
Ronin13 |
Money (IZhO17_money) |
C++14 |
|
1 ms |
336 KB |
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
const int NMAX=1e6+1;
void solve(){
int n;cin>>n;
int a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
set<int>st;
st.insert(-inf);
int l=1;
int r=2;
int cnt=0;
while(r<=n){
int x=*(--st.upper_bound(a[r]));
int y=*(--st.upper_bound(a[l]));
if((a[r]>=a[r-1])&&(x==y)){
r++;
}
else{
cnt++;
for(int i=l;i<r;i++){
st.insert(a[i]);
}
l=r;
r++;
}
}
cnt++;
cout<<cnt<<"\n";
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int test=1;//cin>>test;
while(test--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |