Skip to content

Commit

Permalink
2024.05.02 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
JangHongJoon committed May 2, 2024
1 parent dbe6361 commit fc77b43
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 44 deletions.
19 changes: 0 additions & 19 deletions wkdghdwns199/ACM-25192.py

This file was deleted.

25 changes: 0 additions & 25 deletions wkdghdwns199/ACM-26069.py

This file was deleted.

1 change: 1 addition & 0 deletions wkdghdwns199/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
| 17차시 | 2024.03.27 | DP | <a href="https://www.acmicpc.net/problem/9184">신나는 함수 실행</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/68">2024.03.27</a> |
| 18차시 | 2024.04.03 | 집합과 맵 | <a href="https://www.acmicpc.net/problem/26069">절댓값 힙</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/73">2024.04.03</a> |
| 19차시 | 2024.04.07 | 조합론 | <a href="https://www.acmicpc.net/problem/25192">인사성 밝은 곰곰이</a> | <a href="https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/76">2024.04.07</a> |
| 20차시 | 2024.05.02 | 그리디 | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42862?itm_content=course14743">체육복</a> | <a href="">2024.05.02</a> |

31 changes: 31 additions & 0 deletions wkdghdwns199/그리디/체육복.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.*;

class Solution {
public int solution(int n, int[] lost, int[] reserve) {
Arrays.sort(lost);
Arrays.sort(reserve);
int answer = n-lost.length;
for (int i=0; i<lost.length; i++){
for (int j=0; j<reserve.length; j++){
if (lost[i] == reserve[j]){
answer++;
lost[i] = -1;
reserve[j] = -1;
break;
}
}
}

for (int i=0; i<lost.length; i++){
for (int j=0; j<reserve.length; j++){
if (lost[i]-1 == reserve[j] || lost[i]+1 == reserve[j]){
answer++;
reserve[j]=-1;
break;
}
}
}

return answer;
}
}

0 comments on commit fc77b43

Please sign in to comment.