Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /*
  2. * Matheus Oliveira
  3. * 23/04/2017
  4. * 2219.cpp
  5. */
  6.  
  7. #include <cstdio>
  8. #include <algorithm>
  9.  
  10. #define MAXN 100100
  11.  
  12. int main () {
  13.  
  14. int number_cases, road_length, number_pokestops, i, pokestop_positions[MAXN], j, maximum_distance, distance;
  15.  
  16. scanf("%d", &number_cases);
  17.  
  18. for(i=0; i < number_cases; i++) {
  19.  
  20. scanf("%d %d", &road_length, &number_pokestops);
  21.  
  22. for(j=0; j < number_pokestops; j++) scanf("%d", &pokestop_positions[j]);
  23. std::sort(pokestop_positions, pokestop_positions+number_pokestops);
  24.  
  25. maximum_distance = 0, distance = 0;
  26.  
  27. for(j=0; j < number_pokestops; j++) {
  28.  
  29. if(pokestop_positions[j] > road_length) break;
  30.  
  31. if(pokestop_positions[j] - distance > maximum_distance) maximum_distance = pokestop_positions[j] - distance;
  32. distance = pokestop_positions[j];
  33. }
  34.  
  35. if(road_length-distance > maximum_distance) maximum_distance = road_length-distance;
  36.  
  37. printf("%d\n", maximum_distance);
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement