Submit Info #67995

Problem Lang User Status Time Memory
Static Range Sum cpp wraith_11 AC 149 ms 15.32 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 149 ms 15.29 MiB
max_random_01 AC 148 ms 15.32 MiB
max_random_02 AC 149 ms 15.31 MiB
max_random_03 AC 148 ms 15.32 MiB
max_random_04 AC 148 ms 15.30 MiB
random_00 AC 119 ms 12.32 MiB
random_01 AC 126 ms 13.50 MiB
random_02 AC 75 ms 6.38 MiB
random_03 AC 43 ms 7.25 MiB
random_04 AC 44 ms 6.05 MiB

#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define sz(x) (int)((x).size()) #define fr first #define sc second #define pii pair<int,int> #define rep(i,a,b) for(int i=a;i<b;i++) #define vi vector<int> #define vvi vector<vector<int>> #define vbool vector<bool> #define vvbool vector<vector<bool>> #define vchar vector<char> #define vvchar vector<vector<char>> #define vstring vector<string> #define all(x) (x).begin(), (x).end() #define mem1(a) memset(a,-1,sizeof(a)) #define mem0(a) memset(a,0,sizeof(a)) #define ppc __builtin_popcount #define ppcll __builtin_popcountll const long long INF = 1e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; void solve() { int n, q; cin >> n >> q; vi arr(n); rep(i, 0, n) cin >> arr[i]; vi pre(n, 0); pre[0] = arr[0]; rep(i, 1, n) pre[i] = pre[i - 1] + arr[i]; while (q--) { int l, r; cin >> l >> r; int sum = pre[r - 1] - ((l - 1 < 0) ? 0 : pre[l - 1]); cout << sum << '\n'; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }