Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 오블완
- Python
- GAN
- 힙큐
- 탐욕법
- 프로그래머스
- alogorithm
- cim
- Algorithm
- 현대
- cs공부
- 토이프로젝트
- softeer
- Baekjoon
- 딥러닝
- JavaScript
- 스마트팩토리
- 파이썬
- 현대자동차
- 알고리즘
- 소프티어
- 자바
- Java
- 자바스크립트
- programmers
- boj
- 백준
- heapq
- 티스토리챌린지
- re_lunchu
Archives
- Today
- Total
eaz_coding
[Baekjoon] 11660번 구간 합 구하기 5 본문
문제
https://www.acmicpc.net/problem/11660
풀이
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(1, n+1):
for j in range(1, n+1):
dp[i][j] = arr[i-1][j-1] + dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
for _ in range(m):
x1, y1, x2, y2 = map(int, input().split())
print(dp[x2][y2] - dp[x1-1][y2] - dp[x2][y1-1] + dp[x1-1][y1-1])