From 993a2e80bef0b684f083a89040d8fc8c45b88769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8A=E8=97=A4=20=E8=81=96=E5=A4=9C?= Date: Thu, 4 Jul 2024 13:30:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?paiza=E3=81=AEB117=E3=81=AE=E5=9B=9E?= =?UTF-8?q?=E7=AD=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sitou/src/B117_drivingschool.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 sitou/src/B117_drivingschool.java diff --git a/sitou/src/B117_drivingschool.java b/sitou/src/B117_drivingschool.java new file mode 100644 index 0000000..246cc22 --- /dev/null +++ b/sitou/src/B117_drivingschool.java @@ -0,0 +1,28 @@ +package src; + +import java.util.ArrayList; +import java.util.Scanner; + +public class B117_drivingschool { + public static void main(String[] args) { + final Scanner sc = new Scanner(System.in); + final int howmanyCars = sc.nextInt(); + ArrayList carsList = new ArrayList<>(); + + for(int i = 0; i < howmanyCars; i++){ + carsList.add(sc.nextInt()); + } + + int roundCount = 0; + int outCarsNo = 1; + while(outCarsNo < howmanyCars) { + for(int i = 0; i < howmanyCars; i++) { + if(carsList.get(i) == outCarsNo) outCarsNo++; + } + if(outCarsNo <= howmanyCars) roundCount++; + } + + System.out.println(roundCount); + sc.close(); + } +} -- GitLab From 788a9dca5fd164bfaca7d6f30f7bd98df5ba5677 Mon Sep 17 00:00:00 2001 From: sitou Date: Thu, 4 Jul 2024 07:07:22 +0000 Subject: [PATCH 2/2] =?UTF-8?q?paiza=E3=81=AEB117=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sitou/src/B117_drivingschool.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sitou/src/B117_drivingschool.java b/sitou/src/B117_drivingschool.java index 246cc22..5b6f2bd 100644 --- a/sitou/src/B117_drivingschool.java +++ b/sitou/src/B117_drivingschool.java @@ -16,8 +16,8 @@ public class B117_drivingschool { int roundCount = 0; int outCarsNo = 1; while(outCarsNo < howmanyCars) { - for(int i = 0; i < howmanyCars; i++) { - if(carsList.get(i) == outCarsNo) outCarsNo++; + for(int cuurentCarsNo : carsList) { + if(currentCarsList == outCarsNo) outCarsNo++; } if(outCarsNo <= howmanyCars) roundCount++; } -- GitLab