From a58fe1bfba16af3123a032197a3a9c039167d868 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: Mon, 1 Jul 2024 13:27:18 +0900 Subject: [PATCH 1/3] =?UTF-8?q?paiza=E3=81=AEB095=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/B095_karaoke.java | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sitou/src/B095_karaoke.java diff --git a/sitou/src/B095_karaoke.java b/sitou/src/B095_karaoke.java new file mode 100644 index 0000000..539cf42 --- /dev/null +++ b/sitou/src/B095_karaoke.java @@ -0,0 +1,47 @@ +import java.util.*; + +public class B095_karaoke { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int user = sc.nextInt(); + int music_length = sc.nextInt(); + ArrayList samplepitch = new ArrayList<>(); + + for (int i = 0; i < music_length; i++) { + samplepitch.add(sc.nextInt()); + } + + int highscore = 0; + for (int user_no = 0; user_no < user; user_no++) { + ArrayList userpitch = new ArrayList<>(); + for (int i = 0; i < music_length; i++) { + userpitch.add(sc.nextInt()); + } + int result = calculateScore(userpitch, samplepitch); + highscore = Math.max(highscore, result); + } + + System.out.println(highscore); + } + + + private static int calculateScore(ArrayList userpitch, ArrayList samplepitch) { + int score = 100; + for (int i = 0; i < userpitch.size(); i++) { + int diff = Math.abs(userpitch.get(i) - samplepitch.get(i)); + if (diff <= 5) { + score -= 0; + } else if (diff <= 10) { + score -= 1; + } else if (diff <= 20) { + score -= 2; + } else if (diff <= 30) { + score -= 3; + } else { + score -= 5; + } + } + return score; + } + +} \ No newline at end of file -- GitLab From bb66859336af1b9fad58e6e3b5f858fd52c0eed9 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: Wed, 3 Jul 2024 14:36:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?paiza=E3=81=AEB095=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 --- paiza | 1 + 1 file changed, 1 insertion(+) create mode 160000 paiza diff --git a/paiza b/paiza new file mode 160000 index 0000000..5a6aa46 --- /dev/null +++ b/paiza @@ -0,0 +1 @@ +Subproject commit 5a6aa46033e38819e07b4dc76754a34eb9c21ddb -- GitLab From 21a9db979348cf80e34aefd37675b9401b837df8 Mon Sep 17 00:00:00 2001 From: sitou Date: Wed, 3 Jul 2024 05:50:16 +0000 Subject: [PATCH 3/3] =?UTF-8?q?paiza=E3=81=AEB095=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E2=91=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sitou/src/B095_karaoke.java | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/sitou/src/B095_karaoke.java b/sitou/src/B095_karaoke.java index 539cf42..0f1d76f 100644 --- a/sitou/src/B095_karaoke.java +++ b/sitou/src/B095_karaoke.java @@ -1,34 +1,36 @@ -import java.util.*; +import java.util.ArrayList; +import java.util.Scanner; public class B095_karaoke { public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - int user = sc.nextInt(); - int music_length = sc.nextInt(); - ArrayList samplepitch = new ArrayList<>(); + final Scanner sc = new Scanner(System.in); + final int user = sc.nextInt(); + final int musicLength = sc.nextInt(); + ArrayList samplePitch = new ArrayList<>(); - for (int i = 0; i < music_length; i++) { - samplepitch.add(sc.nextInt()); + for (int i = 0; i < musicLength; i++) { + samplePitch.add(sc.nextInt()); } - int highscore = 0; + int highScore = 0; for (int user_no = 0; user_no < user; user_no++) { - ArrayList userpitch = new ArrayList<>(); + ArrayList userPitch = new ArrayList<>(); for (int i = 0; i < music_length; i++) { - userpitch.add(sc.nextInt()); + userPitch.add(sc.nextInt()); } - int result = calculateScore(userpitch, samplepitch); - highscore = Math.max(highscore, result); + int result = calculateScore(userPitch, samplePitch); + highScore = Math.max(highScore, result); } - System.out.println(highscore); + sc.close(); + System.out.println(highScore); } - private static int calculateScore(ArrayList userpitch, ArrayList samplepitch) { + private static int calculateScore(ArrayList userPitch, ArrayList samplePitch) { int score = 100; - for (int i = 0; i < userpitch.size(); i++) { - int diff = Math.abs(userpitch.get(i) - samplepitch.get(i)); + for (int i = 0; i < userPitch.size(); i++) { + int diff = Math.abs(userPitch.get(i) - samplePitch.get(i)); if (diff <= 5) { score -= 0; } else if (diff <= 10) { @@ -44,4 +46,4 @@ public class B095_karaoke { return score; } -} \ No newline at end of file +} -- GitLab