# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
36148 | Kanvie | Money (IZhO17_money) | C++14 | 413 ms | 6080 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int f[1000001]={0},n,ans=0,trc=0,trc_M,x;
void update(int pos,int value)
{
for (int i=pos; i<=1000000; i+=(i&(-i)))f[i]+=value;
}
int get(int pos)
{
int r=0;
for (int i=pos; i>=1; i-=(i&(-i)))r+=f[i];
return r;
}
int gets(int ll, int rr)
{
return get(rr)-get(ll-1);
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);
stack<int>q;
memset(f,0,sizeof(f));
scanf("%d",&n);
while(n--)
{
scanf("%d",&x);
if(ans==0)
{
q.push(x);
ans++;
trc=x;
trc_M=x;
continue;
}
if(x<trc||(trc_M+1<x&&gets(trc_M+1,x-1)>0))
{
ans++;
trc=x;
trc_M=x;
while(!q.empty())
{
update(q.top(),1);
q.pop();
}
q.push(x);
continue;
}
trc=x;
q.push(x);
}
printf("%d",ans);
}
컴파일 시 표준 에러 (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... |