-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf1713a.cpp
72 lines (63 loc) · 982 Bytes
/
cf1713a.cpp
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// cf1713a
#include <iostream>
#include <cstdlib>
using namespace std;
int solve()
{
int box_count;
cin >> box_count;
int min_x = 0;
int max_x = 0;
int min_y = 0;
int max_y = 0;
while (box_count--)
{
int x;
int y;
cin >> x;
cin >> y;
if (x < min_x)
{
min_x = x;
}
else if (x > max_x)
{
max_x = x;
}
if (y < min_y)
{
min_y = y;
}
else if (y > max_y)
{
max_y = y;
}
}
int moves = 0;
if (min_x < 0)
{
moves += 2 * abs(min_x);
}
if (max_x > 0)
{
moves += 2 * max_x;
}
if (min_y < 0)
{
moves += 2 * abs(min_y);
}
if (max_y > 0)
{
moves += 2 * max_y;
}
return moves;
}
int main()
{
int t;
cin >> t;
while (t--)
{
std::cout << solve() << "\n";
}
}