Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ios::sync_with_stdio(false);
  8. cin.tie(NULL); cout.tie(NULL);
  9. int n, v, z, t;
  10. cin >> n >> v >> z >> t;
  11. int Done[n];
  12. int nowV = t * -1;
  13. for(int x = 0; x < n; x++)
  14. {
  15. Done[x] = nowV + v;
  16. nowV = Done[x];
  17. if(Done[x] < 0)
  18. {
  19. Done[x] = 0;
  20. }
  21. }
  22. int nowZ = 0, time = 0;
  23. for(int x = 0; x < n; x++)
  24. {
  25. time += max(Done[x] - nowZ, 0);
  26. nowZ = max(Done[x], nowZ) + z;
  27. }
  28. cout << time;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement