Official
A - Difference Max Editorial by en_translator
If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Since we want to maximize \(x-y\), we want to make \(x\) as large as possible and \(y\) as small as possible.
Since \(x\) and \(y\) can be chosen independently, it reaches to maximum when \(x = b\) and \(y = c\).
Also, due to the small constraints of \(-100 ≤ x, y ≤ 100\), one can search all possible pairs \((x, y)\).
Sample Code (C++)
#include <iostream>
using namespace std;
int main(){
int a, b, c, d;
cin >> a >> b >> c >> d;
cout << b - c << endl;
}
Sample Code (Python)
a, b = map(int, input().split())
c, d = map(int, input().split())
print(b - c)
posted:
last update: