Skip to content

Commit 780fb65

Browse files
committed
By checker
1 parent 793bc7d commit 780fb65

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

.idea/untitled.iml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

boj/1092/main.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
5+
def solution():
6+
n = int(input())
7+
cranes = list(map(int, input().split()))
8+
m = int(input())
9+
boxes = list(map(int, input().split()))
10+
cnt = 0
11+
12+
cranes.sort(reverse=True)
13+
boxes.sort(reverse=True)
14+
crane_pos = [0] * n
15+
box_check = [True] * m
16+
checked = 0
17+
if cranes[0] < boxes[0]:
18+
print(-1)
19+
return
20+
else:
21+
while checked < m:
22+
for i in range(n):
23+
for j in range(crane_pos[i], m):
24+
if box_check[j] and cranes[i] >= boxes[j]:
25+
crane_pos[i] += 1
26+
box_check[j] = False
27+
checked += 1
28+
break
29+
crane_pos[i] += 1
30+
cnt += 1
31+
print(cnt)
32+
33+
solution()

boj/1092/main/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,14 @@ func main() {
5252
for i := range crains {
5353
for j := crainPos[i]; j < m; j++ {
5454
if !boxCheck[j] && crains[i] >= boxes[j] {
55-
crainPos[i] = j + 1
55+
crainPos[i]++
5656
boxCheck[j] = true
5757
checked++
5858
break
5959
}
60+
crainPos[i]++
6061
}
6162
}
62-
if count > 10000 {
63-
fmt.Printf("%d", -1)
64-
return
65-
}
6663
count++
6764
}
6865
fmt.Printf("%d", count)

0 commit comments

Comments
 (0)