forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
37 lines (31 loc) · 995 Bytes
/
Solution.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static int[] solve(int[] grades){
for (int i = 0; i < grades.length; i++) {
if (grades[i] >= 38) {
int nextMultipleOfFive = 5 - (grades[i] % 5) + grades[i];
if (nextMultipleOfFive - grades[i] < 3) {
grades[i] = nextMultipleOfFive;
}
}
}
return grades;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] grades = new int[n];
for(int grades_i=0; grades_i < n; grades_i++){
grades[grades_i] = in.nextInt();
}
int[] result = solve(grades);
for (int i = 0; i < result.length; i++) {
System.out.print(result[i] + (i != result.length - 1 ? "\n" : ""));
}
System.out.println("");
}
}