Submission #1016284

# Submission time Handle Problem Language Result Execution time Memory
1016284 2024-07-07T16:40:00 Z bachhoangxuan None (JOI16_ho_t5) C++17
100 / 100
94 ms 17076 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
#define int long long

int n,q;

struct BIT{
    int bit[maxn];
    void update(int x,int val){
        for(int i=x;i<=n;i+=(i&(-i))) bit[i]+=val;
    }
    int query(int x){
        int res=0;
        for(int i=x;i>=1;i-=(i&(-i))) res+=bit[i];
        return res;
    }
}c0,c1;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n >> q;
    for(int i=1;i<=n;i++) c0.update(i,1),c1.update(i,1);
    vector<array<int,3>> a;
    for(int i=1;i<=q;i++){
        int x,d,w;cin >> x >> d >> w;w*=2;
        a.push_back({x,d,w});
    }
    reverse(a.begin(),a.end());
    for(auto [x,d,w]:a){
        if(d==1){
            int l=1,r=n;
            while(l<r){
                int m=(l+r+1)>>1;
                if(c0.query(m)<=x) l=m;
                else r=m-1;
            }
            if(c0.query(l)<=x) c1.update(1,-w),c1.update(l+1,w);
        }
        else{
            int l=1,r=n;
            while(l<r){
                int m=(l+r)>>1;
                if(c1.query(m)>x) r=m;
                else l=m+1;
            }
            if(c1.query(l)>x) c0.update(l,w);
        }
    }
    for(int i=1;i<=n;i++) cout << (c0.query(i)-c1.query(i))/2 << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2652 KB Output is correct
35 Correct 2 ms 2648 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 3 ms 2788 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 1 ms 2652 KB Output is correct
48 Correct 1 ms 2652 KB Output is correct
49 Correct 2 ms 2652 KB Output is correct
50 Correct 2 ms 2648 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 2 ms 2664 KB Output is correct
54 Correct 1 ms 2652 KB Output is correct
55 Correct 1 ms 2652 KB Output is correct
56 Correct 2 ms 2652 KB Output is correct
57 Correct 2 ms 2652 KB Output is correct
58 Correct 1 ms 2652 KB Output is correct
59 Correct 1 ms 2652 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 2652 KB Output is correct
62 Correct 2 ms 2652 KB Output is correct
63 Correct 2 ms 2652 KB Output is correct
64 Correct 1 ms 2652 KB Output is correct
65 Correct 1 ms 2652 KB Output is correct
66 Correct 1 ms 2652 KB Output is correct
67 Correct 1 ms 2652 KB Output is correct
68 Correct 1 ms 2652 KB Output is correct
69 Correct 2 ms 2652 KB Output is correct
70 Correct 1 ms 2512 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2512 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 1 ms 2652 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 1 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 1 ms 2652 KB Output is correct
35 Correct 2 ms 2648 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 3 ms 2788 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 1 ms 2652 KB Output is correct
48 Correct 1 ms 2652 KB Output is correct
49 Correct 2 ms 2652 KB Output is correct
50 Correct 2 ms 2648 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 2 ms 2664 KB Output is correct
54 Correct 1 ms 2652 KB Output is correct
55 Correct 1 ms 2652 KB Output is correct
56 Correct 2 ms 2652 KB Output is correct
57 Correct 2 ms 2652 KB Output is correct
58 Correct 1 ms 2652 KB Output is correct
59 Correct 1 ms 2652 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 2652 KB Output is correct
62 Correct 2 ms 2652 KB Output is correct
63 Correct 2 ms 2652 KB Output is correct
64 Correct 1 ms 2652 KB Output is correct
65 Correct 1 ms 2652 KB Output is correct
66 Correct 1 ms 2652 KB Output is correct
67 Correct 1 ms 2652 KB Output is correct
68 Correct 1 ms 2652 KB Output is correct
69 Correct 2 ms 2652 KB Output is correct
70 Correct 1 ms 2512 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 89 ms 12916 KB Output is correct
74 Correct 91 ms 12992 KB Output is correct
75 Correct 90 ms 13004 KB Output is correct
76 Correct 87 ms 12992 KB Output is correct
77 Correct 83 ms 13504 KB Output is correct
78 Correct 86 ms 12208 KB Output is correct
79 Correct 82 ms 13256 KB Output is correct
80 Correct 76 ms 13252 KB Output is correct
81 Correct 67 ms 13232 KB Output is correct
82 Correct 68 ms 12976 KB Output is correct
83 Correct 81 ms 13864 KB Output is correct
84 Correct 72 ms 13332 KB Output is correct
85 Correct 91 ms 13764 KB Output is correct
86 Correct 78 ms 13692 KB Output is correct
87 Correct 79 ms 14452 KB Output is correct
88 Correct 94 ms 17076 KB Output is correct
89 Correct 84 ms 16816 KB Output is correct
90 Correct 80 ms 14060 KB Output is correct
91 Correct 56 ms 12472 KB Output is correct
92 Correct 59 ms 11976 KB Output is correct
93 Correct 83 ms 14288 KB Output is correct
94 Correct 72 ms 12412 KB Output is correct
95 Correct 77 ms 14516 KB Output is correct
96 Correct 70 ms 12484 KB Output is correct
97 Correct 80 ms 14004 KB Output is correct
98 Correct 80 ms 12380 KB Output is correct
99 Correct 87 ms 13496 KB Output is correct
100 Correct 82 ms 12492 KB Output is correct
101 Correct 85 ms 13256 KB Output is correct
102 Correct 85 ms 12736 KB Output is correct
103 Correct 79 ms 14512 KB Output is correct
104 Correct 76 ms 12984 KB Output is correct
105 Correct 71 ms 13260 KB Output is correct
106 Correct 80 ms 12804 KB Output is correct
107 Correct 82 ms 14616 KB Output is correct
108 Correct 74 ms 11956 KB Output is correct
109 Correct 74 ms 14192 KB Output is correct
110 Correct 71 ms 12720 KB Output is correct
111 Correct 85 ms 15588 KB Output is correct
112 Correct 73 ms 13248 KB Output is correct
113 Correct 84 ms 15856 KB Output is correct
114 Correct 84 ms 12980 KB Output is correct
115 Correct 76 ms 12724 KB Output is correct
116 Correct 71 ms 12404 KB Output is correct
117 Correct 83 ms 15032 KB Output is correct
118 Correct 91 ms 12392 KB Output is correct
119 Correct 18 ms 5712 KB Output is correct
120 Correct 14 ms 3932 KB Output is correct