Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit ec1ce03

Browse files
authored
Add files via upload
1 parent 173e798 commit ec1ce03

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

Other/ccchk08j1.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.util.Scanner;
2+
public class ccchk08j1 {
3+
public static void main(String[] args) {
4+
Scanner in = new Scanner (System.in);
5+
int maxC = 0;
6+
int maxN = 0;
7+
8+
int c = in.nextInt();
9+
for (int i = 0; i < c; i++) {
10+
int weightC = in.nextInt();
11+
int lengthC = in.nextInt();
12+
13+
int fishC = weightC * lengthC;
14+
15+
if (fishC >= maxC) {
16+
maxC = fishC;
17+
}
18+
}
19+
20+
int n = in.nextInt();
21+
for (int i = 0; i < n; i++) {
22+
int weightN = in.nextInt();
23+
int lengthN = in.nextInt();
24+
25+
int fishN = weightN * lengthN;
26+
27+
if (fishN >= maxN) {
28+
maxN = fishN;
29+
}
30+
}
31+
32+
if (maxC > maxN) {
33+
System.out.println("Casper");
34+
}
35+
36+
else if (maxN > maxC) {
37+
System.out.println("Natalie");
38+
}
39+
40+
else {
41+
System.out.println("Tie");
42+
}
43+
in.close();
44+
45+
}
46+
}
47+

Other/ccchk08j3.java

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.util.ArrayList;
5+
6+
class PhoneNumber {
7+
String name;
8+
int phoneNumber;
9+
int frequency;
10+
11+
public PhoneNumber(String name, int phoneNumber) {
12+
this.name = name;
13+
this.phoneNumber = phoneNumber;
14+
frequency = 0;
15+
}
16+
17+
public void add() {
18+
frequency++;
19+
}
20+
21+
public void printInfo() {
22+
System.out.println(name + " " + phoneNumber + " " + frequency);
23+
}
24+
}
25+
26+
public class ccchk08j3 {
27+
28+
public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
29+
30+
public static void main(String[] args) throws IOException {
31+
int n = readInt();
32+
33+
ArrayList<PhoneNumber> list = new ArrayList<PhoneNumber>();
34+
35+
String[] input;
36+
for (int i = 0; i < n; i++) {
37+
input = readSpaceInput();
38+
list.add(new PhoneNumber(input[0], Integer.parseInt(input[1])));
39+
}
40+
// for (int i = 0; i < list.size(); i++) {
41+
// System.out.print(list.get(i).name + " ");
42+
// System.out.println(list.get(i).phoneNumber);
43+
// }
44+
45+
int d = readInt();
46+
int phoneNumber;
47+
48+
for (int i = 0; i < d; i++) {
49+
phoneNumber = readInt();
50+
51+
for (int j = 0; j < list.size(); j++) {
52+
if (list.get(j).phoneNumber == phoneNumber) {
53+
list.get(j).add();
54+
break;
55+
}
56+
}
57+
}
58+
59+
int maxValue = 0;
60+
61+
for (int i = 0; i < list.size(); i++) {
62+
if (list.get(i).frequency > maxValue) {
63+
maxValue = list.get(i).frequency;
64+
}
65+
}
66+
67+
int favouriteNumber = 99999999;
68+
String name = "";
69+
for (int i = 0; i < list.size(); i++) {
70+
if (list.get(i).frequency == maxValue && favouriteNumber > list.get(i).phoneNumber) {
71+
favouriteNumber = list.get(i).phoneNumber;
72+
name = list.get(i).name;
73+
}
74+
}
75+
System.out.println(name);
76+
}
77+
78+
public static String readLine() throws IOException {
79+
return in.readLine();
80+
}
81+
82+
public static String readString() throws IOException {
83+
return readLine();
84+
}
85+
86+
public static int readInt() throws IOException {
87+
return Integer.parseInt(readLine());
88+
}
89+
90+
public static long readLong() throws IOException {
91+
return Long.parseLong(readLine());
92+
93+
}
94+
public static double readDouble() throws IOException {
95+
return Double.parseDouble(readLine());
96+
}
97+
98+
public static char readCharacter() throws IOException {
99+
return readLine().charAt(0);
100+
}
101+
102+
public static String[] readSpaceInput() throws IOException {
103+
return in.readLine().split(" ");
104+
}
105+
}

0 commit comments

Comments
 (0)