diff --git a/paiza b/paiza new file mode 160000 index 0000000000000000000000000000000000000000..5a6aa46033e38819e07b4dc76754a34eb9c21ddb --- /dev/null +++ b/paiza @@ -0,0 +1 @@ +Subproject commit 5a6aa46033e38819e07b4dc76754a34eb9c21ddb diff --git a/sitou/src/B095_karaoke.java b/sitou/src/B095_karaoke.java new file mode 100644 index 0000000000000000000000000000000000000000..0f1d76f5ed011ff94fd126f280a0d86e03a76663 --- /dev/null +++ b/sitou/src/B095_karaoke.java @@ -0,0 +1,49 @@ +import java.util.ArrayList; +import java.util.Scanner; + +public class B095_karaoke { + public static void main(String[] args) { + 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 < musicLength; 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); + } + + sc.close(); + 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; + } + +}