Advertisement
Josif_tepe

Untitled

Mar 9th, 2025
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int p1, d1, p2, d2, k;
  7.     cin >> p1 >> d1 >> p2 >> d2 >> k;
  8.    
  9.     vector<int> v(5005, 0);
  10.     for(int i = p1; i < p1 + d1; i++) {
  11.         v[i] = 1;
  12.     }
  13.     int res = 0;
  14.    
  15.     vector<int> tmp = v;
  16.     for(int i = p2 - k; i < p2 - k + d2; i++) {
  17.         tmp[i] = 1;
  18.     }
  19.     int cnt = 0;
  20.     for(int i = 0; i <= 5000; i++) {
  21.         cnt += tmp[i];
  22.     }
  23.     res = max(res, cnt);
  24.     tmp = v;
  25.     for(int i = p2 + k; i < p2 + k + d2; i++) {
  26.         tmp[i] = 1;
  27.     }
  28.      cnt = 0;
  29.     for(int i = 0; i <= 5000; i++) {
  30.         cnt += tmp[i];
  31.     }
  32.     res = max(res, cnt);
  33.    
  34.     v = vector<int>(5005, 0);
  35.     for(int i = p2; i < p2 + d2; i++) {
  36.         v[i] = 1;
  37.     }
  38.    
  39.    
  40.     tmp = v;
  41.     for(int i = p1 - k; i < p1 - k + d1; i++) {
  42.         tmp[i] = 1;
  43.     }
  44.      cnt = 0;
  45.     for(int i = 0; i <= 5000; i++) {
  46.         cnt += tmp[i];
  47.     }
  48.     res = max(res, cnt);
  49.     tmp = v;
  50.     for(int i = p1 + k; i < p1 + k + d1; i++) {
  51.         tmp[i] = 1;
  52.     }
  53.      cnt = 0;
  54.     for(int i = 0; i <= 5000; i++) {
  55.         cnt += tmp[i];
  56.     }
  57.     res = max(res, cnt);
  58.     cout << res << endl;
  59.     return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement