답안 #88417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88417 2018-12-05T18:36:04 Z Bodo171 Money (IZhO17_money) C++14
0 / 100
2 ms 552 KB
#include <iostream>
#include <fstream>
using namespace std;
const int lim=1000*1000;
const int nmax=1000*1000+5;
int aib[nmax],a[nmax];
int n,i,j,secv;
inline int lbit(int x)
{
    return ((x^(x-1))&x);
}
void update(int poz,int val)
{
    for(int idx=poz;idx<=lim;idx+=lbit(idx))
        aib[idx]+=val;
}
int compute(int poz)
{
    int ret=0;
    for(int idx=poz;idx>0;idx-=lbit(idx))
        ret+=aib[idx];
    return ret;
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        update(a[i],1);
    }
    for(i=n;i>=1;i--)
    {
        update(a[i],-1);
        if(i==n||a[i+1]<a[i]||compute(a[i+1])-compute(a[i]))
            secv++;
    }
    cout<<secv;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Incorrect 2 ms 552 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Incorrect 2 ms 552 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Incorrect 2 ms 552 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Incorrect 2 ms 552 KB Output isn't correct
5 Halted 0 ms 0 KB -