Submission #36150

# Submission time Handle Problem Language Result Execution time Memory
36150 2017-12-06T04:21:29 Z Kanvie Money (IZhO17_money) C++14
0 / 100
0 ms 6080 KB
#include<bits/stdc++.h>
using namespace std;
int f[1000001],n,ans=0,trc=0,trc_M,x,mx=0;
void update(int pos,int value)
{
    mx=max(mx,pos);
    for (int i=pos; i<=mx; 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 main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    stack<int>q;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&x);
        if(ans==0||x<trc||(trc_M+1<x&&get(x-1)-get(trc_M)>0))
        {
            ans++;
            trc=x;
            trc_M=x;
            while(!q.empty())
            {
                update(q.top(),1);
                q.pop();
            }
            q.push(x);
        }
        else
        {
            trc=x;
            q.push(x);
        }
    }
    printf("%d",ans);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:19:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
money.cpp:22:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x);
                       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6080 KB Output is correct
2 Correct 0 ms 6080 KB Output is correct
3 Correct 0 ms 6080 KB Output is correct
4 Correct 0 ms 6080 KB Output is correct
5 Correct 0 ms 6080 KB Output is correct
6 Correct 0 ms 6080 KB Output is correct
7 Correct 0 ms 6080 KB Output is correct
8 Correct 0 ms 6080 KB Output is correct
9 Correct 0 ms 6080 KB Output is correct
10 Correct 0 ms 6080 KB Output is correct
11 Correct 0 ms 6080 KB Output is correct
12 Correct 0 ms 6080 KB Output is correct
13 Correct 0 ms 6080 KB Output is correct
14 Correct 0 ms 6080 KB Output is correct
15 Correct 0 ms 6080 KB Output is correct
16 Incorrect 0 ms 6080 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6080 KB Output is correct
2 Correct 0 ms 6080 KB Output is correct
3 Correct 0 ms 6080 KB Output is correct
4 Correct 0 ms 6080 KB Output is correct
5 Correct 0 ms 6080 KB Output is correct
6 Correct 0 ms 6080 KB Output is correct
7 Correct 0 ms 6080 KB Output is correct
8 Correct 0 ms 6080 KB Output is correct
9 Correct 0 ms 6080 KB Output is correct
10 Correct 0 ms 6080 KB Output is correct
11 Correct 0 ms 6080 KB Output is correct
12 Correct 0 ms 6080 KB Output is correct
13 Correct 0 ms 6080 KB Output is correct
14 Correct 0 ms 6080 KB Output is correct
15 Correct 0 ms 6080 KB Output is correct
16 Incorrect 0 ms 6080 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6080 KB Output is correct
2 Correct 0 ms 6080 KB Output is correct
3 Correct 0 ms 6080 KB Output is correct
4 Correct 0 ms 6080 KB Output is correct
5 Correct 0 ms 6080 KB Output is correct
6 Correct 0 ms 6080 KB Output is correct
7 Correct 0 ms 6080 KB Output is correct
8 Correct 0 ms 6080 KB Output is correct
9 Correct 0 ms 6080 KB Output is correct
10 Correct 0 ms 6080 KB Output is correct
11 Correct 0 ms 6080 KB Output is correct
12 Correct 0 ms 6080 KB Output is correct
13 Correct 0 ms 6080 KB Output is correct
14 Correct 0 ms 6080 KB Output is correct
15 Correct 0 ms 6080 KB Output is correct
16 Incorrect 0 ms 6080 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6080 KB Output is correct
2 Correct 0 ms 6080 KB Output is correct
3 Correct 0 ms 6080 KB Output is correct
4 Correct 0 ms 6080 KB Output is correct
5 Correct 0 ms 6080 KB Output is correct
6 Correct 0 ms 6080 KB Output is correct
7 Correct 0 ms 6080 KB Output is correct
8 Correct 0 ms 6080 KB Output is correct
9 Correct 0 ms 6080 KB Output is correct
10 Correct 0 ms 6080 KB Output is correct
11 Correct 0 ms 6080 KB Output is correct
12 Correct 0 ms 6080 KB Output is correct
13 Correct 0 ms 6080 KB Output is correct
14 Correct 0 ms 6080 KB Output is correct
15 Correct 0 ms 6080 KB Output is correct
16 Incorrect 0 ms 6080 KB Output isn't correct