Submission #603330

# Submission time Handle Problem Language Result Execution time Memory
603330 2022-07-24T03:18:05 Z tamthegod Money (IZhO17_money) C++14
100 / 100
173 ms 22860 KB
#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
int n, a[maxN];
int bit[maxN];
void update(int pos, int val)
{
    while(pos < maxN)
    {
        bit[pos] += val;
        pos += (pos & (-pos));
    }
}
int get(int pos)
{
    int res = 0;
    while(pos)
    {
        res += bit[pos];
        pos -= (pos & (-pos));
    }
    return res;
}
void ReadInput()
{
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
}
void Solve()
{
    int res = 1;
    vector<int> bin;
    int last = a[1];
    a[0] = a[1];
    for(int i=1; i<=n; i++)
    {
        bin.pb(a[i]);
      //  update(a[i], 1);
        if(a[i] < a[i - 1])
        {
            res++;
            for(int v : bin) update(v, 1);
            bin.clear();
            last = a[i];
            continue;
        }
        if(i == 5)
        {
            //cout << last;return;
        }
        if(a[i] == a[i - 1]) continue;
        if(get(a[i] - 1) - get(last))
        {
            res++;
            for(int v : bin) update(v, 1);
            bin.clear();
            last = a[i];
        }
    }
    cout << res;
}
int32_t main()
{
  //  freopen("x.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 336 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 2004 KB Output is correct
38 Correct 1 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 596 KB Output is correct
26 Correct 1 ms 596 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 336 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 2004 KB Output is correct
38 Correct 1 ms 2132 KB Output is correct
39 Correct 55 ms 7356 KB Output is correct
40 Correct 100 ms 12060 KB Output is correct
41 Correct 48 ms 6048 KB Output is correct
42 Correct 46 ms 5580 KB Output is correct
43 Correct 29 ms 4068 KB Output is correct
44 Correct 126 ms 15048 KB Output is correct
45 Correct 118 ms 14880 KB Output is correct
46 Correct 124 ms 15172 KB Output is correct
47 Correct 111 ms 14936 KB Output is correct
48 Correct 106 ms 14984 KB Output is correct
49 Correct 137 ms 22860 KB Output is correct
50 Correct 138 ms 22856 KB Output is correct
51 Correct 143 ms 22688 KB Output is correct
52 Correct 131 ms 22716 KB Output is correct
53 Correct 133 ms 22716 KB Output is correct
54 Correct 134 ms 22564 KB Output is correct
55 Correct 158 ms 22636 KB Output is correct
56 Correct 173 ms 22652 KB Output is correct
57 Correct 156 ms 22704 KB Output is correct
58 Correct 153 ms 22696 KB Output is correct
59 Correct 155 ms 22620 KB Output is correct
60 Correct 161 ms 22708 KB Output is correct
61 Correct 151 ms 22708 KB Output is correct
62 Correct 156 ms 22836 KB Output is correct