Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main() {
  10.  
  11. struct lamp {
  12. int distance = 0;
  13. int height = 0;
  14. int count = 0;
  15. };
  16. int N = 0;
  17. int result = 0;
  18. vector<int> road(100);
  19. vector<lamp> array(100);
  20.  
  21. ifstream input("input.txt");
  22. ofstream output("output.txt");
  23.  
  24. input >> N;
  25.  
  26. if (N >= 1) {
  27. for (int i = 0; i < N; i++) {
  28. input >> array[i].distance;
  29. input >> array[i].height;
  30. int l = (array[i].distance - array[i].height);
  31. int r = (array[i].distance + array[i].height);
  32. if (l < 0)
  33. l = 0;
  34. if (r > 99)
  35. r = 99;
  36. for (int j = l; j < r; j++) {
  37. road[j]++;
  38. }
  39. }
  40.  
  41. for (int i = 0; i < 100; i++) {
  42. if (result < road[i]) {
  43. result = road[i];
  44. }
  45. }
  46.  
  47. output << result;
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement