From 5ab3460a7a94b3d24712534b72f369d93b8ad806 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:18:07 +0900 Subject: [PATCH] =?UTF-8?q?[20251022]=20PGM=20/=20Lv2=20/=20=EA=B5=AC?= =?UTF-8?q?=EB=AA=85=EB=B3=B4=ED=8A=B8=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\353\252\205\353\263\264\355\212\270.md" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "0224LJH/202510/22 PGM \352\265\254\353\252\205\353\263\264\355\212\270.md" diff --git "a/0224LJH/202510/22 PGM \352\265\254\353\252\205\353\263\264\355\212\270.md" "b/0224LJH/202510/22 PGM \352\265\254\353\252\205\353\263\264\355\212\270.md" new file mode 100644 index 00000000..1bc67881 --- /dev/null +++ "b/0224LJH/202510/22 PGM \352\265\254\353\252\205\353\263\264\355\212\270.md" @@ -0,0 +1,32 @@ +```java +import java.io.*; +import java.util.*; + +class Solution { + public int solution(int[] people, int limit) { + + Arrays.sort(people); + System.out.println(people); + int front = 0; + int answer = 0; + int back = people.length-1; + + while (front < back){ + if (people[front]+people[back] <= limit){ + answer++; + people[front++] = 0; + people[back--] = 0; + + + } else{ + back--; + } + } + + for (int n: people){ + if (n != 0) answer++; + } + + return answer; + } +}```