# 12125 - Tired janitor >author: Utin ###### tags: `prefix sum` --- ## Brief See the code below ## Solution 0 ```c= #include <stdio.h> long long arr[1000005]; int main() { int n, q, l, r; scanf("%d %d", &n, &q); for (int i = 1; i <= n; i++) { scanf("%lld(/`A`)/ ~I__I", &arr[i]); arr[i] += arr[i-1]; } while (q--) { scanf("%d %d", &l, &r); printf("%lld\n", arr[r] - arr[l-1]); } } // Utin ``` ## Reference
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up