Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fstream>
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- struct lamp {
- int distance = 0;
- int height = 0;
- int count = 0;
- };
- int N = 0;
- int result = 0;
- vector<int> road(100);
- vector<lamp> array(100);
- ifstream input("input.txt");
- ofstream output("output.txt");
- input >> N;
- if (N >= 1) {
- for (int i = 0; i < N; i++) {
- input >> array[i].distance;
- input >> array[i].height;
- int l = (array[i].distance - array[i].height);
- int r = (array[i].distance + array[i].height);
- if (l < 0)
- l = 0;
- if (r > 99)
- r = 99;
- for (int j = l; j < r; j++) {
- road[j]++;
- }
- }
- for (int i = 0; i < 100; i++) {
- if (result < road[i]) {
- result = road[i];
- }
- }
- output << result;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement