Submit Info #66027

Problem Lang User Status Time Memory
Static Range Sum cpp (anonymous) AC 150 ms 15.36 MiB

ケース詳細
Name Status Time Memory
example_00 AC 1 ms 0.45 MiB
max_random_00 AC 150 ms 15.36 MiB
max_random_01 AC 149 ms 15.32 MiB
max_random_02 AC 149 ms 15.36 MiB
max_random_03 AC 148 ms 15.32 MiB
max_random_04 AC 147 ms 15.29 MiB
random_00 AC 119 ms 12.30 MiB
random_01 AC 126 ms 13.42 MiB
random_02 AC 77 ms 6.44 MiB
random_03 AC 44 ms 7.24 MiB
random_04 AC 45 ms 6.05 MiB

#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; #define dbg(x) { cerr << #x << " = " << x << "\n"; } #define pb push_back typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int,int> pi; void solve() { ll n, q; cin >>n >> q; vector<ll> a(n); vector<ll> sums(n); for(int i =0 ; i < n; i++) { cin >> a[i]; } sums[0] = a[0]; for(int i = 1; i < n; i++) { sums[i] = sums[i-1] + a[i]; } while(q--) { int l, r; cin >> l >> r; if(l == 0) { cout << sums[r-1] << "\n"; } else cout << sums[r-1] - sums[l-1] << "\n"; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; // cin >> t; while(t--) { solve(); } return 0; }