-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathACM.java
More file actions
72 lines (53 loc) · 2.37 KB
/
ACM.java
File metadata and controls
72 lines (53 loc) · 2.37 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.util.Scanner;
import java.util.ArrayList;
public class ACM {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Character> problems = new ArrayList<Character>();
ArrayList<Integer> pointTotals = new ArrayList<Integer>();
ArrayList<Boolean> solve = new ArrayList<Boolean>();
for(int i = 0, charNum = 65; i < 26; i++, charNum++)
{
problems.add((char)charNum);
}
for(int i = 0; i < 26; i++)
{
pointTotals.add(0);
}
for(int i = 0; i < 26; i++)
{
solve.add(false);
}
String line = "";
line = sc.nextLine();
do
{
Scanner lineScanner = new Scanner(line);
int minutes = lineScanner.nextInt();
String token = lineScanner.next();
char problem = token.charAt(0);
String solution = lineScanner.next();
if(solution.contentEquals("right") && solve.get(problems.indexOf(problem)) == false)
{
pointTotals.set(problems.indexOf(problem), pointTotals.get(problems.indexOf(problem)) + minutes);
solve.set(problems.indexOf(problem), true);
}
if(solution.contentEquals("wrong") && solve.get(problems.indexOf(problem)) == false)
{
pointTotals.set(problems.indexOf(problem), pointTotals.get(problems.indexOf(problem)) + 20);
}
line = sc.nextLine();
}while(!line.contentEquals("-1"));
int problemsSolved = 0;
int totalScore = 0;
for(int i = 0; i < problems.size(); i++)
{
if(solve.get(i) == true)
{
problemsSolved++;
totalScore += pointTotals.get(i);
}
}
System.out.println(problemsSolved + " " + totalScore);
}
}