• LQDOJ
  • Trang chủ
  • Bài tập
  • Bài nộp
  • Thành viên
  • Kỳ thi
  • Nhóm
  • Giới thiệu
    • Máy chấm
    • Khóa học
    • Đề xuất ý tưởng
    • Đề xuất bài tập
    • Tools
    • Báo cáo tiêu cực
    • Báo cáo lỗi

Tiếng Việt

Tiếng Việt
English

Đăng nhập

Đăng ký

ihydra1611

  • Giới thiệu
  • Bài tập
  • Bài nộp

Rating
-
Bài tập
12
Điểm
5566
Rating #
-
Điểm #
8680

Giới thiệu

include <bits/stdc++.h>

define forr(i,l,r) for (int i=l;i<=r;i++)

define ford(i,r,l) for (int i=r;i>=l;i--)

define yes cout <<"YES\n"

define no cout <<"NO\n"

define fi first

define se second

define ull unsigned long long

define ll long long

define sz(s) s.size()

define el "\n"

define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int a[100005];
int n;
void update(int i, int val){
while(i <= n ){
a[i]+= val;
i += (i&-i);
}
}
int get(int i){
int sum = 0;
while(i){
sum+=a[i];
i-=(i&-i);
}
return sum;
}
void solve(){
int q,x,u,v,t;
cin >> n;
cin >> q;

forr(i,1,n) {
    cin >> x;
    update(i,x);
}
while(q--){
        cin >> t >> u >> v;
        if(t == 1) update(u,v);
        else {
            if(u == 1) cout << get(v) << endl;
            else cout << get(v)-get(u-1)<<endl;
        }


}

}
signed main()
{ faster;
int t=1;
///cin >> t;
while(t--) solve();

return 0;

}


«    »
Thứ 2
Thứ 3
Thứ 4
Thứ 5
Thứ 6
Thứ 7
CN
Ít
Nhiều

proudly powered by DMOJ| developed by LQDJudge team