Skip to content

Commit 3f12c16

Browse files
committed
feat(codeforces): implement solution for p2189A
1 parent 67b70fa commit 3f12c16

File tree

2 files changed

+39
-3
lines changed
  • src/main
    • java/com/lzw/solutions/codeforces/p2189A
    • resources/codeforces/p2189A

2 files changed

+39
-3
lines changed

src/main/java/com/lzw/solutions/codeforces/p2189A/Main.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,32 @@ public class Main {
1010
private static final PrintWriter out = new PrintWriter(System.out, true);
1111

1212
private static void solve() throws IOException {
13-
// your code here
13+
String[] first = in.readLine().split(" ");
14+
int n = Integer.parseInt(first[0]);
15+
int h = Integer.parseInt(first[1]);
16+
int l = Integer.parseInt(first[2]);
17+
18+
String[] line = in.readLine().split(" ");
19+
int cntRow = 0;
20+
int cntCol = 0;
21+
22+
for (String s : line) {
23+
int x = Integer.parseInt(s);
24+
if (x <= h) cntRow++;
25+
if (x <= l) cntCol++;
26+
}
27+
28+
int maxPairs = Math.min(cntRow, cntCol);
29+
maxPairs = Math.min(maxPairs, n / 2);
30+
31+
out.println(maxPairs);
1432
}
1533

1634
public static void main(String[] args) throws IOException {
17-
solve();
35+
int t = Integer.parseInt(in.readLine());
36+
while (t-- > 0) {
37+
solve();
38+
}
1839
out.close();
1940
}
20-
}
41+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
7
2+
2 1 1
3+
1 1
4+
5 2 2
5+
1 2 2 3 2
6+
8 4 2
7+
7 2 2 2 3 4 4 2
8+
7 3 6
9+
10 4 1 3 5 4 6
10+
2 4 4
11+
5 5
12+
7 6 3
13+
10 4 1 3 5 4 6
14+
4 1 1
15+
1 1 1 1

0 commit comments

Comments
 (0)