11659: 구간 합 구하기 4

myeongrangcoding·2023년 12월 15일
0

백준

목록 보기
25/47

https://www.acmicpc.net/problem/11659

구현 26분

풀이

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;
long Array[100001];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//freopen("input.txt", "rt", stdin);

	int N{}, M{};
	cin >> N >> M;

	for (int i = 1; i <= N; ++i)
	{
		cin >> Array[i];
		Array[i] += Array[i - 1];
	}

	int i{}, j{};
	for (int k = 0; k < M; ++k)
	{
		cin >> i >> j;
		cout << Array[j] - Array[i - 1] << '\n';
	}

	return 0;
}
profile
명랑코딩!

0개의 댓글