Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2cda3a

Browse files
committed
Today ps
1 parent 0b46201 commit c2cda3a

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

‎Baekjoon/Python/1781.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
que = []
5+
last = 0
6+
score = 0
7+
arr = [[] for _ in range(200000)]
8+
n = int(input())
9+
for _ in range(n):
10+
d, w = map(int, input().split())
11+
arr[d - 1].append(w)
12+
last = max(last, d)
13+
for d in range(last - 1, -1, -1):
14+
for w in arr[d]:
15+
que.append(w)
16+
if len(arr[d]) > 0:
17+
que.sort()
18+
if len(que) > 0:
19+
score += que.pop()
20+
print(score)

‎Baekjoon/Python/2636.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from collections import deque
2+
from copy import deepcopy
3+
import sys
4+
input = sys.stdin.readline
5+
6+
DY = [0, 0, 1, -1]
7+
DX = [1, -1, 0, 0]
8+
ans = 0
9+
n, m = map(int, input().split())
10+
arr = []
11+
vst = []
12+
copy_vst = []
13+
cur = 0
14+
for y in range(n):
15+
arr.append(list(map(int, input().split())))
16+
vst.append([])
17+
copy_vst.append([])
18+
for x in range(m):
19+
vst[y].append(True)
20+
copy_vst[y].append(True)
21+
cur += int(arr[y][x] == 1)
22+
23+
def melt(round):
24+
que = deque([(0, 0)])
25+
while len(que) > 0:
26+
y, x = que.pop()
27+
if not (y < n and 0 <= y and x < m and 0 <= x) or not vst[y][x]:
28+
continue
29+
vst[y][x] = False
30+
if arr[y][x] == 1:
31+
arr[y][x] = round
32+
continue
33+
elif arr[y][x] == round:
34+
continue
35+
for i in range(4):
36+
que.appendleft((y + DY[i], x + DX[i]))
37+
38+
def get_count():
39+
cnt = 0
40+
for y in range(n):
41+
for x in range(m):
42+
cnt += int(arr[y][x] == 1)
43+
return cnt
44+
45+
last = get_count()
46+
round = 2
47+
while last > 0:
48+
cur = last
49+
melt(round)
50+
ans += 1
51+
vst = deepcopy(copy_vst)
52+
round += 1
53+
last = get_count()
54+
print(ans)
55+
print(cur)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /