We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a992f5e commit a2b07c2Copy full SHA for a2b07c2
1 file changed
1366/A/Main.java
@@ -0,0 +1,28 @@
1
+import java.util.Scanner;
2
+
3
+public class Main {
4
+ public static void main(String[] args) {
5
+ Scanner sc = new Scanner(System.in);
6
7
+ int t = sc.nextInt();
8
+ for (int tc = 0; tc < t; ++tc) {
9
+ int a = sc.nextInt();
10
+ int b = sc.nextInt();
11
12
+ System.out.println(solve(a, b));
13
+ }
14
15
+ sc.close();
16
17
18
+ static int solve(int a, int b) {
19
+ int common = Math.min(a, b);
20
+ int extra = a + b - common * 2;
21
22
+ if (extra >= common) {
23
+ return common;
24
25
26
+ return extra + (common - extra) / 3 * 2 + (((common - extra) % 3 == 2) ? 1 : 0);
27
28
+}
0 commit comments