TLE求调
查看原帖
TLE求调
1406896
crafting_table楼主2024/10/30 20:01

TLE求调

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXX = 5e5+5;
int n,m;
int a[MAXX];
int opt,x,y;
int ans;

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i = 1;i <= n;i++){cin>>a[i];}
    while(m--)
    {
        cin>>opt>>x>>y;
        if(opt==1){a[x] += y;}
        else
        {
            ans = 0;
            for(int i = x;i <= y;i++)
            {
                ans += a[i];
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}
2024/10/30 20:01
加载中...