Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <math.h>
  5.  
  6. void main() {
  7. int num_of_req, reqs_per_sec;
  8. int index = 0;
  9. int current_requests = 1;
  10. int* timestamps;
  11.  
  12. if(scanf("%d %d", &num_of_req, &reqs_per_sec) == 2) {
  13. }
  14. timestamps = (int*)malloc(num_of_req * sizeof(int));
  15.  
  16. if(scanf("%d", &timestamps[0]) == 1) {
  17. }
  18.  
  19. for (int i = 1; i < num_of_req; i++) {
  20. if (scanf("%d", &timestamps[i]) == 1) {
  21. }
  22.  
  23. if (timestamps[index] <= timestamps[i] - 1000){
  24. index++;
  25. }
  26. else {
  27. current_requests++;
  28. }
  29. }
  30. float servers_required = ceil((float)current_requests / (float)reqs_per_sec);
  31. printf("%d", (int)servers_required);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement