Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- using namespace std;
- void main(void) {
- ifstream fin("react.in");
- ofstream fout("react.out");
- vector <long long> vec1;
- vector <long long> vec2;
- long long maxvaluex = 0, maxvaluey = 0, numberoflines = 0;
- int counter = 1, counter2 = 0, maxv = 0, peresech = 0;
- long long bottonleftx = 0, bottonlefty = 0, bottonrightx = 0, bottonrighty = 0;
- double temp = 0;
- fin >> maxvaluex >> maxvaluey >> numberoflines;
- for (int i = 0; i < numberoflines; i++)
- {
- fin >> bottonleftx >> bottonlefty >> bottonrightx >> bottonrighty;
- temp = maxvaluey * bottonleftx / bottonrighty;
- if (temp > maxvaluex)
- {
- temp = (maxvaluey - (maxvaluex * bottonrighty / bottonleftx)) + maxvaluex;
- }
- if ((maxvaluey * bottonleftx / bottonrighty) != long long(maxvaluey * bottonleftx / bottonrighty))
- {
- vec1.push_back(temp + 1);
- }
- else
- {
- vec1.push_back(temp);
- }
- if ((maxvaluey * bottonrightx / bottonlefty) > maxvaluex)
- {
- vec2.push_back((maxvaluey - (maxvaluex * bottonlefty / bottonrightx)) + maxvaluex);
- }
- vec2.push_back(maxvaluey * bottonrightx / bottonlefty);
- }
- 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 = 0; i < numberoflines - 1; i++)
- {
- if (vec1[i+1] > vec2[counter2])
- {
- counter--;
- counter2++;
- i--;
- }
- else
- {
- counter++;
- if (counter > maxv)
- {
- maxv = counter;
- peresech = vec1[i+1];
- }
- }
- }
- if (peresech > maxvaluex)
- {
- fout << maxv << " " << maxvaluex << " " << -(peresech - maxvaluex - maxvaluey);
- }
- else
- {
- fout << maxv << " " << peresech << " " << maxvaluey;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement