1 条题解

  • 1
    @ 2024-12-18 13:00:44
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    const int INF = 0x3f3f3f3f;
    const int N = 1e6 + 10;
    int n , m , x , l , r;
    int a [N];
    signed main()
    {
    
    	    cin >> n >> m;
    	    for(int i = 1; i <= n; i++)
    		{
    		    cin >> x;
    		    a [i] = a [i - 1] + x;
    	    }
    	    for(int i = 1; i <= m; i++)
    		{
    		    cin >> l >> r;
    		    cout << a [r] - a [l - 1] << "\n";
    	    }
    		return 0;
    }
    
    • 1

    信息

    ID
    3146
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    (无)
    递交数
    28
    已通过
    14
    上传者