Advertisement
Guest User

Problem E

a guest
Feb 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6.  
  7. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  8. #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
  9. #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  10.  
  11. int main() {
  12.     optimize();
  13.     ll x1, x2, x3, x4, h;
  14.     cin >> x1 >> x2 >> x3 >> x4 >> h;
  15.     if (x1 > x3 && x2 > x4) swap(x1, x3), swap(x2, x4);
  16.     if (x2 <= x3) cout << "0" << endl;
  17.     else if (x1 <= x3 && x4 <= x2) cout << (x4 - x3) * h << endl;
  18.     else if (x3 <= x1 && x2 <= x4) cout << (x2 - x1) * h << endl;
  19.     else if (x3 < x2) cout << (x2 - x3) * h << endl;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement