Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MuchanKim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2025.03.29 | κ΅¬ν˜„ | [개미](https://www.acmicpc.net/problem/3048)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/3|
| 2μ°¨μ‹œ | 2025.04.11 | μ—λΌν† μŠ€ν…Œλ„€μŠ€μ˜μ±„ | [μ†Œ-λ‚œλ‹€!](https://www.acmicpc.net/problem/19699)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/10|
| 3μ°¨μ‹œ | 2025.04.29 | 그리디 | [μ•Œλ°”μƒ κ°•ν˜Έ](https://www.acmicpc.net/problem/1758)|https://github.com/AlgoLeadMe/AlgoLeadMe-14/pull/14|

---
28 changes: 28 additions & 0 deletions MuchanKim/그리디/μ•Œλ°”μƒκ°•ν˜Έ.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

func solution(_ n: Int, _ tips: [Int]) -> Int {
let sortedTips = tips.sorted(by: >)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ²˜μŒμ— μ €λŠ” κ·Έλƒ₯ sortedν–ˆλ‹€κ°€ λœ¬κΈˆμ—†μ΄ ν‹€λ €μ„œ κΈ‰ν•˜κ²Œ reversed λ„£μ–΄μ£Όκ³  λ§žμ·„λŠ”λ°, byμ“°λŠ”κ±Έ κΉœλ°•ν–ˆλ„€μš”! πŸ‘ μžŠμ§€μ•Šκ² μŠ΅λ‹ˆλ‹€.

var sortedArr = arr.sorted().reversed()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ¬΄μš°λŠ” μ—­μ‹œ


var totalTip = 0
for i in 0..<sortedTips.count {
let actualTip = sortedTips[i] - i
if actualTip > 0 {
totalTip += actualTip
}
Comment on lines +7 to +11
Copy link
Collaborator

@bishoe01 bishoe01 May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사싀상 λ™μΌν•œ 것 κ°™μŠ΅λ‹ˆλ‹€!
μ €λŠ” μ½”λ“œκΈΈμ΄ 쀄여주렀고 enumerated()λž‘ μ‚Όν•­μ—°μ‚°μž μ‚¬μš©ν–ˆμ–΄μš”!
λ¬΄μ„ μƒλ‹˜μ΄ 더 이해가 μž˜λ˜λŠ” 쒋은 μ½”λ“œλ„€μš” πŸ‘

for (idx, value) in sortedArr.enumerated() {
        answer += value - idx > 0 ? value - idx : 0
    }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bishoe01 finn쌀 저도 enumerated() μΌμ–΄μš© !!! ν•€μŒ€λ„ Hoxy~~~ python??? λ„ˆλ‘? μ•Ό λ‚˜λ‘ γ…‹γ…‹

}

return totalTip
}
Comment on lines +3 to +15
Copy link
Collaborator

@YooGyeongMo YooGyeongMo May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이게 κ·Έλ¦¬λ””λŠ” 같이 μ ‘κ·Όν–ˆλŠ”λ° μ €λŠ” enumrated() ν•¨μˆ˜λ‘œ index와 valueλ₯Ό ν•¨κ»˜ λ±‰μ–΄μ£ΌλŠ” ν•¨μˆ˜λ‘œ μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€. !

import Foundation


// μ›λž˜ μ£Όλ €κ³  ν–ˆλ˜λˆ -(받은 λ“±μˆ˜ - 1) 만큼 νŒμ„ κ°•ν˜Έμ—κ²Œ μ€€λ‹€.
// μŒμˆ˜λŠ” 0
// 제일 많이 λ°›λŠ” 법은 κ°€μž₯ ν°μˆ˜κ°€ μ•žμ— 였고 0λ“±μœΌλ‘œ μ˜€λŠ”λ²•μ΄λ‹€.
let n = Int(readLine()!)!

var numbers: [Int] = []

for _ in 0..<n {
    let num = Int(readLine()!)!
    numbers.append(num)
}

numbers.sort(by:>) // λ‚΄λ¦Όμ°¨μˆœ

var maxTip = 0

for (idx,tip) in numbers.enumerated() {
    let takeTip = tip - idx
    guard takeTip > 0 else { break} // 뒀에꺼 λ‹€ λŒν•„μš”μ—†μŒ
    
    maxTip += takeTip
}

print(maxTip)

μ—¬κΈ°μ„œ μ €λŠ” 2κ°€μ§€λ₯Ό κΉ¨λ‹«λŠ”λ°μš”.

  1. μΈλ±μŠ€μ΄λ―€λ‘œ λ“±μˆ˜μ—μ„œ - 1 ν•˜λŠ” 연산을 쀄이기 μœ„ν•΄μ„œλŠ” 인덱슀 κ·ΈλŒ€λ‘œ μ“°λ©΄λœλ‹€ !
  2. guard문이 μžˆμœΌλ―€λ‘œ 전체 쑰건을 λ‹€ 돌 ν•„μš”μ—†κ³ , λ¬Έμ œμ—μ„œ μš”κ΅¬ν•˜λŠ” 쑰건 밑은 체크할 ν•„μš”μ—†μœΌλ―€λ‘œ guard문을 μ‚¬μš©ν•˜μž.

사싀 무 μ½”λ“œλ₯Ό λ³΄λ‹ˆ γ…‹γ…‹ enumrated()λŠ” λ„ˆλ¬΄ λΉ‘λŒ€κ°ˆ λ§Ήν‚€λ‘œ λ³΄λŠ”λ°λ‘œ κ΅¬ν˜„μ΄μ§€ μ•Šμ•˜λ‚˜μ‹Άμ–΄μš”.


++ μ €μ˜ 개인적인 μƒκ°μž…λ‹ˆλ‹€.

무가 μ½”ν…Œ κ²½ν—˜μ΄ μžˆμœΌμ‹  λŸ¬λ„ˆλΆ„μ—κ²Œ μ—¬μ­€λ³΄μ…¨λ‹€ν–ˆλŠ”λ°, μ €μ˜ 생각은 쑰금 λ‹€λ¦…λ‹ˆλ‹€.

기좜문제만 보아도, API μž‘μ„± λ¬Έμ œκ°€ 많고 μ΄λ²ˆμ— μ½”ν…Œ ν‘Ό 문제 2λ²ˆμ€ 아에 λŒ€λ†“κ³  APIμž‘μ„±λ¬Έμ œ ( 카카였, 넀이버식) -> 이 말은 즉, ν•¨μˆ˜λ³„λ‘œ λ‚˜λˆ μ„œ νŒŒλΌλ―Έν„°λ₯Ό 잘 μ΄μš©ν•˜λŠλƒ. (νŒŒλΌλ―Έν„° ν•¨μˆ˜ ν”„λ ˆμž„ 골격 μˆ˜μ •κ°€λŠ₯ν•˜λŠλƒ ? -> 삼성에선 λΆˆκ°€λŠ₯ν–ˆμŠ΅λ‹ˆλ‹€. ) κ·Έλž˜μ„œ ν•¨μˆ˜λ₯Ό λ§Œλ“€κ³  λ‘œμ§λ³„λ‘œ 잘 λ‚˜λˆ„λŠ”κ²ƒμ€ ν•„μš”ν•˜λ‹€ μƒκ°ν•©λ‹ˆλ‹€.

κ·ΈλŸ¬λ‚˜ λ§Œμ•½ λ¬Έμ œμ— λŒ€ν•œ 이해도도 μ—†λŠ”λ° λ‚˜λˆ„κ³  μžˆλŠ”κ²ƒμ€ λΆ„λͺ… λΉ„νš¨μœ¨μ μΈκ²ƒμ€ λ§žμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μ—°μŠ΅ν• λ•Œ μ‘°μ°¨ κ·Έλƒ₯ 맨땅에 쀄쀄 μ λŠ”κ²ƒμ€ μ•ˆμ’‹μ€ μŠ΅κ΄€μΈκ±° κ°™μŠ΅λ‹ˆλ‹€.

μ € λ˜ν•œ ν•¨μˆ˜λ‘œ 적지 μ•Šκ³  μ΄λ²ˆμ— κ·Έλƒ₯ μ œμΆœν•˜μ˜€μœΌλ‚˜, ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€ + ν…Œν¬ κΈ°μ—… + 사기업 쑰차도 λ‹€ API μš”κ΅¬ 쑰건이며 μ œκ°€ μ³€μ—ˆλ˜ μ‚Όμ„± μ½”ν…Œ 쑰차도 정말 λ³΅μž‘ν•œ κ΅¬ν˜„μ΄κ³  반볡적인 create , delete , updateλ₯Ό μ•Œκ³ λ¦¬μ¦˜μ˜ μ§€μ‹μœΌλ‘œ μ–Όλ§ˆλ‚˜ μ΅œμ ν™”μ‹œν‚€λŠλƒμ˜€μŠ΅λ‹ˆλ‹€.(1번 λ¬Έμ œκ°€ λΉ‘κ΅¬ν˜„μ΄μ§€λ§Œ κ²°κ΅­ μ•Œκ³ λ³΄λ©΄ create, delete, update μ˜€μŠ΅λ‹ˆλ‹€. ) κ·Έλž˜μ„œ μ‚Όμ„±μ—μ„œλŠ” 2문제λ₯Ό 4μ‹œκ°„μ„ μ€€λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. 반볡적인 연산은 즉, ν•¨μˆ˜λ₯Ό 적극 ν™œμš©ν•˜λΌλΌλŠ” 뜻으둜 ν•΄μ„λ©λ‹ˆλ‹€.

λ˜ν•œ, μ œκ°€ μ³€μ—ˆλ˜ μ†Œλ§ˆ μ½”ν…Œμ—μ„œλŠ” μ•ž 2λ¬Έμ œμ—μ„œλŠ” 되게 μ‰½κ²Œ ν’€λ Έμ§€λ§Œ λ’·λ¬Έμ œλ“€μ€ ν•¨μˆ˜λ₯Ό κ΅¬λΆ„μ§“κ±°λ‚˜ λ‚΄κ°€ μ΄ν•΄ν•œλ°”κ°€ μ •ν™•ν•˜κ²Œ λ‘œμ§λ³„λ‘œ λΆ„λ¦¬μ‹œμΌœλ†“μ§€ μ•Šκ³  쀄쀄푼닀면 μ ˆλŒ€ 풀리지 μ•Šμ„ λ¬Έμ œλ“€μ΄μ—ˆμŠ΅λ‹ˆλ‹€. -> SQL 문제 λ˜ν•œ CTE 가상 ν…Œμ΄λΈ” ν‘œν˜„μœΌλ‘œ ν’€μ—ˆμ„λ•Œλ„ μ–΄λ–»κ²Œλ³΄λ©΄ ν•¨μˆ˜μ²˜λŸΌ λ‚΄κ°€ μƒκ°ν•œ 것듀을 λͺ¨λ“ˆν™”λ₯Ό 잘 μ‹œν‚€λŠλƒμ˜€μŠ΅λ‹ˆλ‹€.

μ €λŠ” λ¬΄λ‚˜ κΈΈ μ½”λ“œλ₯Ό λ³΄λ©΄μ„œ λ°˜μ„± 많이 ν•©λ‹ˆλ‹€. 길은 주석을 정말 꼼꼼히 μž‘μ„±ν•˜κ³  그것도 MARKλ₯Ό ν™œμš©ν•˜μ—¬, + μŠ€μœ„ν”„ν‹°ν•˜κ²Œ guard문을 ν™œμš©ν•œλ‹€λŠ”κ²ƒ μ§€κΈˆμ€ 되게 좔가적인 κΈ°νšŒλΉ„μš©μ΄ λ“€μ–΄κ°€μ§€λ§Œ μ΄ν›„μ—λŠ” 정말 빛을 λ°œν• κ²ƒμž…λ‹ˆλ‹€. λ˜ν•œ 무가 μž‘μ„±ν•˜λŠ” ν•¨μˆ˜λ³„λ‘œ λ‘œμ§λΆ„λ¦¬, 이게 μ§€κΈˆ λ‹Ήμž₯ μ½”ν…Œμ˜ 연속이라면 λ³„λ‘œλ‹€ ! 라고 ν•  수 μžˆκ² μŠ΅λ‹ˆλ‹€λ§Œ...( 사싀 μ™œ λ³„λ‘œμΈμ§€ μ €λŠ” 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€... γ…‹... ) μ €λŠ” μ—°μŠ΅λ•Œ μ €λ ‡κ²Œ ν•΄λ†“μœΌλ©΄ 좔후에 문제λ₯Ό λ³΄μ•˜μ„λ•Œ μ–΄λ–»κ²Œ λΆ„λ¦¬μ‹œν‚¬μ§€ λ˜ν•œ λ””λ²„κΉ…μ‹œμ— μ‹œκ°„μ„ 정말 λ‹¨μΆ•μ‹œν‚¬ 수 μžˆλ‹€λŠ” μ μ—μ„œ μ €λŠ” 무쑰건 적극 μ°¬μ„±μž…λ‹ˆλ‹€. -> μ•± μ „ν˜•μ€ μ½”ν…Œλ„ μžˆμ§€λ§Œ 과제 μ „ν˜•λ„ μžˆκΈ°μ—..

λ¬Όλ‘  μ € 말씀을 ν•˜μ‹  λŸ¬λ„ˆ λΆ„μ˜ 말씀도 이해가 κ°€μ§€λ§Œ μ €λŠ” μ € 말을 κ²½κ³„ν•˜κ³  μ½”ν…Œλ₯Ό μ€€λΉ„ν•˜λŠ” μž…μž₯μ—μ„œλŠ” μ‘°μ‹¬μŠ€λ ˆ μ˜κ²¬μ„ λ‚΄λ΄…λ‹ˆλ‹€.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ§Œμ•½ λŸ¬λ„ˆλ“€λΌλ¦¬μ˜ 말이 λ­”κ°€ 쑰금 ν—·κ°ˆλ¦¬μ‹œκ³  받아듀이기에 νž˜λ“œμ‹ λ‹€κ³  νŒλ‹¨λ˜μ‹œλ©΄ μ €λŠ” ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€μ—μ„œ 카카였 기좜, μ‚Όμ„± 기좜, 타 κΈ°μ—… 기좜 λ¬Έμ œλ“€μ„ ν’€μ–΄λ³΄μ‹œκ³  λ‚˜μ„œ νŒλ‹¨ν•˜μ‹œλ©΄ μ’‹μ„λ“―ν•©λ‹ˆλ‹€. λΆ„λͺ… 좜제 동ν–₯κ³Ό νŠΈλ Œλ“œλŠ” λ³€ν•˜μ§€λ§Œ ν˜„μž¬ νŠΈλ Œλ“œλŠ” κ·ΈλŸ°κ±°κ°™μŠ΅λ‹ˆλ‹€.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쒋은 κΈ€ κ°μ‚¬ν•©λ‹ˆλ‹€.
저도.. ν˜Ήμ‹œ 도움이 λ κΉŒν•˜μ—¬ TMI에 λŒ€ν•œ 제 생각을 μ–˜κΈ°ν•΄λ³΄μžλ©΄
(사싀 μ œκ°€ 이런 μ–˜κΈ°λ₯Ό ν•  μžκ²©μ€ μ—†μŠ΅λ‹ˆλ‹€..)

가독성과 ꡬ쑰 vs μ‹€μ „ 속도

κ°€ λ”± 고민의 주제라고 생각이 λ“€μ—ˆμ–΄μš”..

"이걸 ꡳ이 ν•¨μˆ˜λ‘œ λΊ„κΉŒ?"
"λ³€μˆ˜λͺ… μ‹ κ²½ μ“°λŠ”κ²Œ 의미 μžˆλ‚˜?" λΌλŠ” 고민도 의미 μžˆλ‹€κ³  λ΄μš”.

ν•˜μ§€λ§Œ μ €λŠ” λ‹¨μˆœν•˜κ²Œ "μ–΄μ°¨ν”Ό 디버깅 해야돼" λΌλŠ” 생각을 κ°€μ§€κ³  μžˆμŠ΅λ‹ˆλ‹€.

생각해보면, line1λΆ€ν„° print()κΉŒμ§€ μˆ˜μ • μ•ˆν•΄λ³Έ μ½”λ“œλŠ” μ—†λŠ” 것 κ°™κ΅¬μš”..
λ””λ²„κΉ…ν•˜λ €λ©΄... 가독성과 ꡬ쑰가 μ—†μœΌλ©΄.. λΆˆκ°€λŠ₯..μ΄λ‹ˆκΉŒμš”..

그리고 μš°λ¦¬κ°€ μž˜ν•˜κ³ μž ν•˜λŠ” 것은 버그 ZERO μ½”λ“œλ₯Ό μ§œλŠ”κ²Œ μ•„λ‹Œ,
가독성과 ꡬ쑰, 그리고 버그가 적은 μ½”λ“œλ₯Ό μ§œλŠ”κ²Œ μ•„λ‹Œκ°€ μ‹ΆμŠ΅λ‹ˆλ‹€!!


그리고 νšŒμ‚¬μ—μ„œλ„ 개발만 μž˜ν•˜λŠ”κ²Œ μ•„λ‹Œ 버그λ₯Ό 잘 νŒŒμ•…ν•˜κ³  μž‘λŠ” μ‚¬λžŒμ„ μ›ν•˜μ§€ μ•Šμ„κΉŒ μ‹Άλ„€μš” ~!!
(그러렀면 μ½”ν…Œλ„ 정성껏. 풀닀보면. 속도도 λŠ˜μ–΄λ‚˜μ§€ μ•Šμ„κΉŒμš”~~??)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giljihun @일둠머슀크 μ—¬κΈ° μΈμž¬μžˆμ–΄μ˜ˆ... @timcook μ—¬κΈ° μΈμž¬μžˆμ–΄μ˜ˆ

Copy link
Collaborator Author

@MuchanKim MuchanKim May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

크... 진심어린 μ‘°μ–Έ κ°μ‚¬ν•©λ‹ˆλ‹€ λ‹€λ“€..! μΌ€μ–΄μ•€μ„œν¬νŠΈ μ§€λŒ€λ£¨λ„€μš”. 이런 TMI자주 μ˜¬λ €μ•Όκ² μ–΄μš”.

μ’‹κ²Œ λ΄μ£Όμ‹œλ‹ˆ λ‹€ν–‰μž…λ‹ˆλ‹€!

λ§ν•˜μ‹ λŒ€λ‘œ λͺ¨λ“ˆν™”ν•˜λŠ” 것이 μ €λŠ” μ’‹λ‹€κ³  μƒκ°ν•˜κ³  μžˆμ–΄μš”.
ν•œλ²ˆμ— ν’€λ¦¬λŠ” κ²½μš°λŠ” λ“œλ¬ΌκΈ° λ•Œλ¬Έμ— λͺ¨λ“ˆμ„ λ‚˜λˆ„λŠ”κ²Œ κ²°κ΅­μ—” 더 빨리 ν‘ΈλŠ” 방법이라고 μƒκ°ν•΄μš”. ν•˜λ“œμ½”λ”©ν•˜λ©΄ μ–΄λ””μ„œλΆ€ν„° 고쳐야할지 λ§‰λ§‰ν•˜μž–μ•„μš”? 가독성도 λ–¨μ–΄μ§€κ³ !

ν•˜μ§€λ§Œ 문제λ₯Ό ν’ˆμ— μžˆμ–΄μ„œ λΆˆν•„μš”ν•œ μš”μ†Œλ“€. ν•¨μˆ˜λͺ…을 κ³ λ―Όν•œλ‹€λ˜μ§€, μž‘μ€ κΈ°λŠ₯이라도 λ‹€ ν•¨μˆ˜λ‘œ μͺΌκ° λ‹€λ˜μ§€. 이런 뢀뢄듀을 λ‹€μ‹œν•œλ²ˆ 고민해봐야할 것 κ°™κΈ΄ν•΄μš”. μ‹€μ œλ‘œ 문제 ν’€ λ•Œ 넀이밍을 κ³ λ―Όν•˜λŠ” νŽΈμ΄κΈ΄ν•©λ‹ˆλ‹€..

λ‹€ λͺΈμœΌλ‘œ μ²΄λ“ν•˜λŠ” 과정이라 μƒκ°ν•˜κ³  μ΄λ ‡κ²Œλ„ 해보고 μ €λ ‡κ²Œλ„ ν•΄λ³΄λ €κ³ μš”! κ·Έλ ‡κ²Œ μ €λ§Œμ˜ 기쀀을 λ§Œλ“€μ–΄κ°€λ©΄ λ˜λŠ” 것 μ•„λ‹ˆκ² μŠ΅λ‹ˆκΉŒ?

λͺ¨λ‘ κ°μ‚¬ν•΄μš”!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MuchanKim 무!! μš”μ‹œ !! 이쿠죠 !

Comment on lines +3 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solution!
ν™•μ‹€νžˆ κ°€λ…μ„±μ΄λ‚˜ ꡬ쑰가 λͺ…ν™•ν•΄μ„œ λ„ˆλ¬΄ μ’‹μ€λ°μš”?

무 문제λ₯Ό ν’€λ•Œλ©΄
저도 잘 λ‚˜λˆ„μ§€μ•Šλ˜(?) λͺ¨μŠ΅μ„ λ°˜μ„±ν•˜κ³ μž
μž‘κ²Œλ‚˜λ§ˆ ν•¨μˆ˜λ₯Ό λ‚˜λˆ λ³΄κ³ μž ν•˜λ„€μš”~!

// 팁 계산 ν•¨μˆ˜
func calculateTip(_ tip: Int, _ order: Int) -> Int {
    var realTip = tip - (order - 1)
    
    realTip = realTip < 0 ? 0 : realTip
    
    return realTip
}


// μ†λ‹˜ 수 μž…λ ₯
let n = Int(readLine()!)!

// 각 μ†λ‹˜μ˜ 팁 μž…λ ₯
var tips: [Int] = []
for _ in 0..<n {
let tip = Int(readLine()!)!
tips.append(tip)
}
Comment on lines +17 to +25
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μž…λ ₯λ°›λŠ” λΆ€λΆ„ κ°€μ Έλ‹€ μΌμŠ΅λ‹ˆλ” πŸ‘

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν•€ μž…λ ₯ λ°›λŠ” λΆ€λΆ„ κ°€μ Έλ‹€ μ“°λŠ”κ±° 보고 저도 그러고 μžˆμ–΄μš” γ…‹γ…‹γ…‹


let res = solution(n, tips)
print(res)