-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path1271C.cpp
More file actions
executable file
·49 lines (41 loc) · 986 Bytes
/
1271C.cpp
File metadata and controls
executable file
·49 lines (41 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Problem Code: 1271C
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void shawarma_tent(int n, int sx, int sy, vector<int>& x, vector<int>& y) {
int c, px, py;
vector<int> pos(4);
for (int i = 0; i < n; i++) {
if (y[i] < sy)
pos[0]++;
else if (y[i] > sy)
pos[1]++;
if (x[i] < sx)
pos[2]++;
else if (x[i] > sx)
pos[3]++;
}
px = sx;
py = sy;
c = distance(pos.begin(), max_element(pos.begin(), pos.end()));
if (c == 0) // Tent lies at the top side of school
py = sy - 1;
else if (c == 1) // Tent lies at the bottom side of school
py = sy + 1;
else if (c == 2) // Tent lies at the left side of school
px = sx - 1;
else // Tent lies at the right side of school
px = sx + 1;
cout << pos[c] << endl;
cout << px << " " << py;
}
int main() {
int n, sx, sy;
cin >> n >> sx >> sy;
vector<int> x(n), y(n);
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i];
shawarma_tent(n, sx, sy, x, y);
return 0;
}