Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- void main(void) {
- ifstream fin("react.in");
- ofstream fout("react.out");
- long long maxvaluex = 0, maxvaluey = 0, numberoflines = 0;
- int counter = 1, counter2 = 0, maxv = 0, peresech = 0;
- vector <long long> vec1;
- vector <long long> vec2;
- fin >> maxvaluex >> maxvaluey >> numberoflines;
- int* bottomleftx = new int[numberoflines];
- int* bottomlefty = new int[numberoflines];
- int* bottomrightx = new int[numberoflines];
- int* bottomrighty = new int[numberoflines];
- for (int i = 0; i < numberoflines; i++) {
- fin >> bottomleftx[i] >> bottomlefty[i] >> bottomrightx[i] >> bottomrighty[i];
- }
- for (int i = 0; i < numberoflines; i++) {
- if ((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) > maxvaluex) {
- if (((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex) != long long(((maxvaluey * bottomleftx[i]) / bottomrighty[i]))) {
- vec1.push_back((((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex) + 1);
- }
- else {
- vec1.push_back(((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex);
- }
- }
- else {
- if ((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) != long long(((maxvaluey * bottomleftx[i]) / bottomrighty[i]))) {
- vec1.push_back(((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + 1);
- }
- else {
- vec1.push_back((maxvaluey * bottomleftx[i]) / bottomrighty[i]);
- }
- }
- }
- for (int i = 0; i < numberoflines; i++)
- {
- if ((long double)((maxvaluey * bottomrightx[i]) / bottomlefty[i]) > maxvaluex) {
- vec2.push_back(maxvaluey - (maxvaluex * bottomlefty[i] / bottomrightx[i]) + maxvaluex);
- }
- else {
- vec2.push_back(((maxvaluey * bottomrightx[i]) / bottomlefty[i]));
- }
- }
- sort(vec1.begin(), vec1.end());
- sort(vec2.begin(), vec2.end());
- /*int tempforsortvec1 = 0;
- for (int i = 0; i < vec1.size() - 1; i++) {
- for (int j = 0; j < vec1.size() - i - 1; j++) {
- if (vec1[j] > vec1[j + 1]) {
- tempforsortvec1 = vec1[j];
- vec1[j] = vec1[j + 1];
- vec1[j + 1] = tempforsortvec1;
- }
- }
- }
- int tempforsortvec2 = 0;
- for (int i = 0; i < vec2.size() - 1; i++) {
- for (int j = 0; j < vec2.size() - i - 1; j++) {
- if (vec2[j] > vec2[j + 1]) {
- tempforsortvec2 = vec2[j];
- vec2[j] = vec2[j + 1];
- vec2[j + 1] = tempforsortvec2;
- }
- }
- }*/
- for (int i = 1; i < numberoflines; i++)
- {
- if (vec1[i] <= vec2[counter2])
- {
- counter++;
- if (counter > maxv)
- {
- maxv = counter;
- peresech = vec1[i];
- }
- }
- else
- {
- counter--;
- counter2++;
- i--;
- }
- }
- if (peresech > maxvaluex)
- {
- fout << maxv << " " << maxvaluex << " " << -(peresech - maxvaluex - maxvaluey);
- }
- else
- {
- fout << maxv << " " << peresech << " " << maxvaluey;
- }
- delete[] bottomleftx;
- delete[] bottomlefty;
- delete[] bottomrightx;
- delete[] bottomrighty;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement