Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Matheus Oliveira
- * 23/04/2017
- * 2219.cpp
- */
- #include <cstdio>
- #include <algorithm>
- #define MAXN 100100
- int main () {
- int number_cases, road_length, number_pokestops, i, pokestop_positions[MAXN], j, maximum_distance, distance;
- scanf("%d", &number_cases);
- for(i=0; i < number_cases; i++) {
- scanf("%d %d", &road_length, &number_pokestops);
- for(j=0; j < number_pokestops; j++) scanf("%d", &pokestop_positions[j]);
- std::sort(pokestop_positions, pokestop_positions+number_pokestops);
- maximum_distance = 0, distance = 0;
- for(j=0; j < number_pokestops; j++) {
- if(pokestop_positions[j] > road_length) break;
- if(pokestop_positions[j] - distance > maximum_distance) maximum_distance = pokestop_positions[j] - distance;
- distance = pokestop_positions[j];
- }
- if(road_length-distance > maximum_distance) maximum_distance = road_length-distance;
- printf("%d\n", maximum_distance);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement