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 c875f40

Browse files
committed
[20220821] 307 Contest 참가 (결과: 3점)
1 parent f7b4179 commit c875f40

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

‎contest/weekly/307/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Weekly Contest 307
2+
3+
https://leetcode.com/contest/weekly-contest-307
4+
5+
### 2383. Minimum Hours of Training to Win a Competition
6+
문제 이해 하는데 오랜 시간이 걸렸다.
7+
8+
O(N) 으로 energy, experience 리스트를 순회하면서 현재의 energy, experience 값을 바꿔주면 되는 문제였다.
9+
10+
헤맸던 부분은 예를 들면 현재 에너지 4일 때 4의 적을 무찌를 수 있는지 (?) 가 문제에 명확하게 나와있지 않아서 헷갈렸다.
11+
그래서 감으로 0이 될 때는 경쟁할 수 없다고 생각해서 +1 을 더해주었고 이후에 계산 실수를 해서 시도 1번을 날려먹었다.
12+
13+
### 2384. Largest Palindromic Number
14+
이런 문제는 여러번 풀어봤다고 생각했는데.... leading zero 에서 실패해서 못풀었다.
15+
우선순위 큐를 써서 내림차순 숫자의 문자열로 순회했는데, 예외 케이스에 걸려서 실패함
16+
17+
### 2385. Amount of Time for Binary Tree to Be Infected
18+
트리는 자신 있었는데 1번에서 시간을 너무 잡아먹어서 3번 근처도 가지 못했다 ᅮ
19+
start 에 해당하는 노드까지의 depth 와 전체 depth 를 더하면 된다고 생각했는데 역시 예외 케이스(한쪽으로만 확장된 트리일 때)에 걸려 실패하였다.
20+
21+
## 결과
22+
1번 1개 풀어서 3점이다 흑흑
23+
오늘 문제가 좀 어려웠던 듯...
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int],
6+
experience: List[int]) -> int:
7+
result = 0
8+
9+
for e in energy:
10+
if e < initialEnergy:
11+
initialEnergy -= e
12+
else:
13+
e1 = e - initialEnergy + 1
14+
initialEnergy = e1 + initialEnergy - e
15+
result += e1
16+
17+
for e in experience:
18+
if e < initialExperience:
19+
initialExperience += e
20+
else:
21+
e1 = e - initialExperience + 1
22+
initialExperience += e1 + e
23+
result += e1
24+
25+
return result
26+
27+
28+
if __name__ == '__main__':
29+
sol = Solution()
30+
print(sol.minNumberOfHours(5, 3, [1, 4, 3, 2], [2, 6, 3, 1]))
31+
print(sol.minNumberOfHours(2, 4, [1], [3]))
32+
print(sol.minNumberOfHours(1, 1, [1, 1, 1, 1], [1, 1, 1, 50]))

0 commit comments

Comments
(0)

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