Submission #700131

# Submission time Handle Problem Language Result Execution time Memory
700131 2023-02-18T16:42:18 Z fdnfksd Money (IZhO17_money) C++14
100 / 100
244 ms 57108 KB
#include<bits/stdc++.h>
#define TASKNAME "bieudo"
#define pb push_back
#define pli pair<int,int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=1e6+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll bit[maxN];
ll a[maxN];
vector<ll> vec[maxN];
ll n;
void update(ll i,ll val)
{
    while(i<=1e6)
    {
        bit[i]+=val;
        i+=(i&(-i));
    }
}
ll get(ll i)
{
    ll cc=0;
    while(i>0)
    {
        cc+=bit[i];
        i-=(i&(-i));
    }
    return cc;
}
ll getlr(ll i,ll j)
{
    if(i>j) return 0;
    return get(j)-get(i-1);
}
void solve()
{
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    a[0]=0;
    ll cnt=0;
    for(int i=1;i<=n;i++)
    {
        ll j=i+1;
        cnt++;
        vec[cnt].pb(a[i]);
        while(j<=n&&a[j]>=a[j-1])
        {
            vec[cnt].pb(a[j]);
            j++;
        }
        i=j-1;
    }
    for(auto zz:vec[1])
    {
        update(zz,1);
    }
    ll ans=cnt;
    for(int i=2;i<=cnt;i++)
    {
        ll pre=vec[i][0];
        for(int j=1;j<vec[i].size();j++)
        {
            if(getlr(pre+1,vec[i][j]-1)>0)
            {
                ans++;
                pre=vec[i][j];
            }
        }
        for(auto zz:vec[i])
        {
            update(zz,1);
        }
    }
    cout << ans;
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}

Compilation message

money.cpp: In function 'void solve()':
money.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for(int j=1;j<vec[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 11 ms 23812 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 11 ms 23852 KB Output is correct
5 Correct 12 ms 23852 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23836 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23900 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 12 ms 23832 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23764 KB Output is correct
14 Correct 12 ms 23888 KB Output is correct
15 Correct 12 ms 23892 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 11 ms 23812 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 11 ms 23852 KB Output is correct
5 Correct 12 ms 23852 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23836 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23900 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 12 ms 23832 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23764 KB Output is correct
14 Correct 12 ms 23888 KB Output is correct
15 Correct 12 ms 23892 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
17 Correct 11 ms 23892 KB Output is correct
18 Correct 11 ms 23892 KB Output is correct
19 Correct 12 ms 23892 KB Output is correct
20 Correct 13 ms 23848 KB Output is correct
21 Correct 12 ms 23892 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23748 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 12 ms 23976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 11 ms 23812 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 11 ms 23852 KB Output is correct
5 Correct 12 ms 23852 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23836 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23900 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 12 ms 23832 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23764 KB Output is correct
14 Correct 12 ms 23888 KB Output is correct
15 Correct 12 ms 23892 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
17 Correct 11 ms 23892 KB Output is correct
18 Correct 11 ms 23892 KB Output is correct
19 Correct 12 ms 23892 KB Output is correct
20 Correct 13 ms 23848 KB Output is correct
21 Correct 12 ms 23892 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23748 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 12 ms 23976 KB Output is correct
27 Correct 12 ms 23764 KB Output is correct
28 Correct 12 ms 23860 KB Output is correct
29 Correct 11 ms 23764 KB Output is correct
30 Correct 12 ms 23764 KB Output is correct
31 Correct 12 ms 23836 KB Output is correct
32 Correct 12 ms 23944 KB Output is correct
33 Correct 12 ms 23832 KB Output is correct
34 Correct 13 ms 23920 KB Output is correct
35 Correct 13 ms 23848 KB Output is correct
36 Correct 11 ms 23892 KB Output is correct
37 Correct 13 ms 25184 KB Output is correct
38 Correct 12 ms 25216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23764 KB Output is correct
2 Correct 11 ms 23812 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 11 ms 23852 KB Output is correct
5 Correct 12 ms 23852 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23836 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23900 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 12 ms 23832 KB Output is correct
12 Correct 12 ms 23764 KB Output is correct
13 Correct 14 ms 23764 KB Output is correct
14 Correct 12 ms 23888 KB Output is correct
15 Correct 12 ms 23892 KB Output is correct
16 Correct 12 ms 23892 KB Output is correct
17 Correct 11 ms 23892 KB Output is correct
18 Correct 11 ms 23892 KB Output is correct
19 Correct 12 ms 23892 KB Output is correct
20 Correct 13 ms 23848 KB Output is correct
21 Correct 12 ms 23892 KB Output is correct
22 Correct 11 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 12 ms 23748 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 12 ms 23976 KB Output is correct
27 Correct 12 ms 23764 KB Output is correct
28 Correct 12 ms 23860 KB Output is correct
29 Correct 11 ms 23764 KB Output is correct
30 Correct 12 ms 23764 KB Output is correct
31 Correct 12 ms 23836 KB Output is correct
32 Correct 12 ms 23944 KB Output is correct
33 Correct 12 ms 23832 KB Output is correct
34 Correct 13 ms 23920 KB Output is correct
35 Correct 13 ms 23848 KB Output is correct
36 Correct 11 ms 23892 KB Output is correct
37 Correct 13 ms 25184 KB Output is correct
38 Correct 12 ms 25216 KB Output is correct
39 Correct 87 ms 35340 KB Output is correct
40 Correct 135 ms 43540 KB Output is correct
41 Correct 68 ms 32972 KB Output is correct
42 Correct 66 ms 32544 KB Output is correct
43 Correct 49 ms 29992 KB Output is correct
44 Correct 166 ms 48372 KB Output is correct
45 Correct 162 ms 47960 KB Output is correct
46 Correct 164 ms 48376 KB Output is correct
47 Correct 146 ms 45384 KB Output is correct
48 Correct 155 ms 46620 KB Output is correct
49 Correct 191 ms 56332 KB Output is correct
50 Correct 189 ms 55756 KB Output is correct
51 Correct 198 ms 56696 KB Output is correct
52 Correct 183 ms 55816 KB Output is correct
53 Correct 185 ms 56156 KB Output is correct
54 Correct 190 ms 55888 KB Output is correct
55 Correct 211 ms 57068 KB Output is correct
56 Correct 224 ms 57052 KB Output is correct
57 Correct 212 ms 56996 KB Output is correct
58 Correct 208 ms 57052 KB Output is correct
59 Correct 214 ms 56972 KB Output is correct
60 Correct 207 ms 57108 KB Output is correct
61 Correct 244 ms 57104 KB Output is correct
62 Correct 206 ms 57104 KB Output is correct