aboutsummaryrefslogtreecommitdiff
path: root/contests/Starters41/D
diff options
context:
space:
mode:
Diffstat (limited to 'contests/Starters41/D')
-rwxr-xr-xcontests/Starters41/D/inp6
-rwxr-xr-xcontests/Starters41/D/main.cpp26
2 files changed, 32 insertions, 0 deletions
diff --git a/contests/Starters41/D/inp b/contests/Starters41/D/inp
new file mode 100755
index 0000000..55e3ef3
--- /dev/null
+++ b/contests/Starters41/D/inp
@@ -0,0 +1,6 @@
+5
+3 4
+5 5
+7 3
+5 2
+7 12
diff --git a/contests/Starters41/D/main.cpp b/contests/Starters41/D/main.cpp
new file mode 100755
index 0000000..a0365c2
--- /dev/null
+++ b/contests/Starters41/D/main.cpp
@@ -0,0 +1,26 @@
+#include<bits/stdc++.h>
+#include <cmath>
+
+using namespace std;
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--){
+ int x, y;
+ cin >> x >> y;
+ if(x > y) {
+ if((x - y) % 2 == 0) {
+ cout << (x - y) / 2 << endl;
+ } else {
+ cout << (x - y) / 2 + 2 << endl;
+ }
+ } else if (y > x) {
+ cout << y - x << endl;
+ } else {
+ cout << 0 << endl;
+ }
+ }
+}