Submission #88518

# Submission time Handle Problem Language Result Execution time Memory
88518 2018-12-06T09:53:46 Z Bodo171 Money (IZhO17_money) C++14
0 / 100
2 ms 508 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];
    }
    for(i=1;i<=n;i++)
    {
        update(a[i],1);
        j=i;
        while(j<n&&a[j]<a[j+1]&&compute(a[j+1])-compute(a[i])==0)
            j++;
        secv++;
        i=j;
    }
    cout<<secv;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -