# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168937 | beso123 | Money (IZhO17_money) | C++14 | 1198 ms | 62072 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1000006;
int n,a[N],fen[N],ans;
set <int> st;
void UPD(int x,int val){
while(x<=N){
fen[x]+=val;
x=x+(x&(-x));
}
}
int GET(int x){
int sum=0;
while(x>=1){
sum+=fen[x];
x=x-(x&(-x));
}
return sum;
}
int get(int l,int r){
if(l>r)
return 0;
return GET(r)-GET(l-1);
}
main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
scanf("%lld",&n);
for(int k=1;k<=n;k++){
scanf("%lld",&a[k]);
}
int l=1;
for(int r=1;r<=n+1;r++){
if(a[r-1]>a[r]){
ans++;
for(int j=l;j<=r-1;j++)
st.insert(a[j]);
l=r;
continue;
}
auto it=st.upper_bound(a[l]);
if(it!=st.end() && *it<a[r]){
ans++;
for(int j=l;j<=r-1;j++)
st.insert(a[j]);
l=r;
}
}
printf("%lld",ans);
return 0;
}
컴파일 시 표준 에러 (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... |