# FBC - Editorial

Div-4 Contest

Author: Arpit Kesharwani
Tester: Anshu Garg
Editorialist: Akshat Gupta

CAKEWALK

# PROBLEM:

Chef has a bucket having a capacity of K liters. It is already filled with X liters of water.

Find the maximum amount of extra water in liters that Chef can fill in the bucket without overflowing.

# EXPLANATION:

Given a Bucket having K litres of capacity out of which X litres is already filled.
Let Y be the Extra amount which is filled in bucket
so X + Y is the total amount of water.
Amount of Water \leq Capacity of water
X + Y \leq K
\Rightarrow Y \leq K - X
From the above Equation
Y_{\max} = K - X
Hence the Answer to the Problem is K - X

# SOLUTIONS:

Setter's Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin >> t;
while(t--)
{
int k,x;
cin>>k>>x;
cout<<k-x <<endl;
}
return 0;
}

Tester's Solution
#include<bits/stdc++.h>
using namespace std ;

#define ll              long long
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (ll)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll>
#define pii             pair<int,int>
#define ld              long double

template<typename T, typename U> static inline void amin(T &x, U y){ if(y < x) x = y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x < y) x = y; }

#ifdef LOCAL
#define debug(...) debug_out(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 2401
#endif

long long readInt(long long l,long long r,char end){
long long x = 0;
int cnt = 0;
int first =-1;
bool is_neg = false;
while(true) {
char g = getchar();
if(g == '-') {
assert(first == -1);
is_neg = true;
continue;
}
if('0' <= g && g <= '9') {
x *= 10;
x += g - '0';
if(cnt == 0) {
first = g - '0';
}
++cnt;
assert(first != 0 || cnt == 1);
assert(first != 0 || is_neg == false);

assert(!(cnt > 19 || (cnt == 19 && first > 1)));
}
else if(g == end) {
if(is_neg) {
x = -x;
}
assert(l <= x && x <= r);
return x;
}
else {
assert(false);
}
}
}
string ret = "";
int cnt = 0;
while(true) {
char g = getchar();
assert(g != -1);
if(g == end) {
break;
}
++cnt;
ret += g;
}
assert(l <= cnt && cnt <= r);
return ret;
}
long long readIntSp(long long l,long long r){
}
long long readIntLn(long long l,long long r){
}
}
}

int _runtimeTerror_()
{
int mn_K = 2000, mx_K = 0;
for(int i=1;i<=T;++i) {
int X = readIntLn(1, K - 1);
cout << K - X << "\n";
amax(mx_K, K);
amin(mn_K, K);
cerr << K << " " << X << "\n";
}
assert(getchar() == -1);
return 0;
}

int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef runSieve
sieve();
#endif
#ifdef NCR
initncr();
#endif
int TESTS = 1;
//cin >> TESTS;
while(TESTS--) {
_runtimeTerror_();
}
return 0;
}