Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int n, x, y, k;
- int ctv[] = {0,0,0,0}, Ax[]= {0,0,0,0}, Ay[] = {0,0,0,0}, R[]= {0,0,0,0}, A_sum[] = {5000, 5000, 5000, 5000};
- int main()
- {
- cin >> n;
- for(int i = 0; i < n; i++)
- {
- cin >> x >> y;
- if(x > 0 && y > 0)
- {
- ctv[0]++;
- if(A_sum[0] < min(abs(x), abs(y)))
- {
- A_sum[0] = min(abs(x), abs(y));
- Ax[0] = x;
- Ay[0] = y;
- if (abs(x)>abs(y)) R[0] = abs(x);
- else R[0]= abs(y);
- }
- }
- else if (x < 0 && y > 0)
- {
- ctv[1]++;
- if(A_sum[1] < min(abs(x), abs(y)))
- {
- A_sum[1] = min(abs(x), abs(y));
- Ax[1] = x;
- Ay[1] = y;
- if (abs(x)>abs(y)) R[1] = abs(x);
- else R[1]= abs(y);
- }
- }
- else if (x < 0 && y < 0)
- {
- ctv[2]++;
- if(A_sum[2] < min(abs(x), abs(y)))
- {
- A_sum[2] = min(abs(x), abs(y));
- Ax[2] = x;
- Ay[2] = y;
- if (abs(x)>abs(y)) R[2] = abs(x);
- else R[2]= abs(y);
- }
- }
- else if ( x > 0 && y < 0)
- {
- ctv[3]++;
- if(A_sum[3] < min(abs(x), abs(y)))
- {
- A_sum[3] = min(abs(x), abs(y));
- Ax[3] = x;
- Ay[3] = y;
- if (abs(x)>abs(y)) R[3] = abs(x);
- else R[3]= abs(y);
- }
- }
- }
- int t = 5000000;
- if(ctv[0] <> 0 && ctv[0] < t)
- {
- t = ctv[0];
- k = 1;
- }
- if(ctv[1] <> 0 && ctv[1] < t)
- {
- t = ctv[1];
- k = 2;
- }
- else if (t == ctv[1]) if R[1] > R[k - 1] k = 2;
- if(ctv[2] <> 0 && ctv[2] < t)
- {
- t = ctv[2];
- k = 3;
- }
- else if (t == ctv[2]) if (R[2] > R[k - 1]) k = 3;
- if(ctv[3] <> 0 && ctv[3] < t)
- {
- t = ctv[3];
- k = 4;
- }
- else if(t == ctv[3]) if (R[3] > R[k - 1]) k = 4;
- cout << "K = "<< k << endl;
- cout<< "M = " <<ctv[k - 1] << endl;
- cout<< "A = (" << Ax[k - 1]<<','<<' '<<Ay[k - 1]<<')'<<endl;
- cout<<"R = "<< R[k - 1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement