Skip to content

Commit

Permalink
staticrangesum
Browse files Browse the repository at this point in the history
  • Loading branch information
megargayu committed Oct 8, 2022
1 parent 32650ae commit 477f064
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions other/staticrangesum/staticrangesum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// https://judge.yosupo.jp/problem/static_range_sum

#include <bits/stdc++.h>
using namespace std;

#define MAX_N 500000
#define ll long long

vector<ll> ps(MAX_N + 1);

int main()
{
int N, Q;
cin >> N >> Q;

ps[0] = 0;

int a, b;
for (int i = 1; i <= N; ++i)
{
cin >> a;
ps[i] = ps[i - 1] + a;
}

for (int i = 0; i < Q; ++i)
{
cin >> a >> b;
cout << ps[b] - ps[a] << '\n';
}

return 0;
}

0 comments on commit 477f064

Please sign in to comment.