Skip to content

Commit

Permalink
Merge pull request #88 from AlgoLeadMe/22-LJEDD2
Browse files Browse the repository at this point in the history
22-LJEDD2
  • Loading branch information
LJEDD2 authored Mar 9, 2024
2 parents ad6feda + b3904ac commit 2a472fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions LJEDD2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
| 19차시 | 2024.02.24 | 구현 | <a href="https://www.acmicpc.net/problem/16919">봄버맨 2</a> | [#76](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/76) |
| 20차시 | 2024.02.27 | BFS | <a href="https://www.acmicpc.net/problem/6593">상범 빌딩 2</a> | [#80](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/80) |
| 21차시 | 2024.03.01 | 정수론 | <a href="https://www.acmicpc.net/problem/21920">서로소 평균 2</a> | [#83](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/83) |
| 22차시 | 2024.03.04 | 수학(애드 혹) | <a href="https://www.acmicpc.net/problem/28419">더하기 </a> | [#88](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/88) |
---
10 changes: 10 additions & 0 deletions LJEDD2/애드 혹/더하기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
n = int(input())
n_list = list(map(int,input().split()))
diff = sum(n_list[1::2]) - sum(n_list[::2])

# N=3이고 홀수합이 더 많다면 불가능
if n == 3 and diff < 0 :
print(-1)
# 그 외에는 절댓값의 차이 만큼 +1
else:
print(abs(diff))

0 comments on commit 2a472fb

Please sign in to comment.