Problem Statement
Warning: Embedded in this problem statement is an image that may not be visible if you are using a plugin. For best results, view this problem in the standard Arena editor.
The left-handed Finnish hockey player Slaapi Shotti has a spectacular move where he fires the puck from the blue line, off the boards, and into the net. The relevant portion of an international hockey rink is shown below.
The rink is 3000 centimeters (cm) wide. The distance between the blue line and the goal line is 1733 cm. Centered on the goal line is the goal itself, which is 183 cm wide and marked with a goalpost at each end. When Slaapi shoots, the puck will travel in a straight line from a given point on the blue line, rebound symmetrically from the right border of the rink, and continue traveling in a straight line. We shall model the puck and the goalposts as infinitesimal points on the ice.
Positioned on the ice are up to nine players, whom we model as line segments that are 50 cm long and parallel to the blue line. Each player must stand on or below the goal line, at least one centimeter above the blue line, and at least one centimeter away from the sides. Players may overlap or coincide. In order for Slaapi to score a goal, the puck may not intersect a player's line segment at any point, including its endpoints. For the purposes of player position as well as puck rebound, you may ignore the curvature of the rink and assume that the boards are perfectly straight, forming a rectangle with the blue line and goal line.
Slaapi must shoot the puck from the point on the blue line whose distance
from the left border of the rink is given by the
Calculate the angle, measured counterclockwise from the blue line,
at which Slaapi must shoot the puck so that its point of intersection
with the goal line is between the goalposts, inclusively, and as close
as possible to the right goalpost. Return your answer in degrees as a
Definition
- Class:
- PuckShot
- Method:
- caromAngle
- Parameters:
- int, int[], int[]
- Returns:
- double
- Method signature:
- double caromAngle(int puckCoord, int[] xCoords, int[] yCoords)
- (be sure your method is public)
Constraints
- puckCoord is between 1 and 2999, inclusive
- xCoords contains between one and nine elements, inclusive
- yCoords contains the same number of elements as xCoords
- each element of xCoords is between 26 and 2974, inclusive
- each element of yCoords is between 1 and 1733, inclusive
- the input is such that the rightmost gap through which Slaapi can score, if any, is at least 1.0e-6 cm wide at the goal line
Examples
2833
{1500, 1580}
{1730, 1730}
Returns: 47.022170720170784
Two players are positioned near the goal, one in the center and another by the right goalpost. Between them is a gap that lets Slaapi score a goal. He puts the puck as close to the right goalpost as possible.
2833
{2690}
{500}
Returns: 44.88563731851585
A single player not far from the blue line forces Slaapi to put the puck near the left goalpost.
2833
{2690, 2676}
{500, 500}
Returns: -1.0
Two players not far from the blue line are completely blocking Slaapi's shot.
2900
{1500, 1580, 2200, 2600}
{1730, 1730, 1000, 500}
Returns: 46.79257639615244
55
{1479, 1427, 2556, 2834, 2866, 2958, 2763, 2899, 2630}
{1708, 1726, 487, 471, 121, 446, 473, 266, 380}
Returns: 21.706043385046158
1809
{1571}
{1730}
Returns: 33.18726534329994
The player's right endpoint is exactly in the way of the right goalpost, so Slaapi must shoot to the left of the player.
1
{1831}
{1629}
Returns: 21.464425628113574
11
{1668}
{1693}
Returns: 21.508782280926084
115
{1504, 1430, 2568, 2477, 2767, 2507, 2645, 2684, 2838}
{1732, 1720, 281, 228, 173, 472, 325, 225, 229}
Returns: 21.980648511094003
2839
{1472, 1550, 2905, 2692, 2687, 2688, 2854, 2798, 2950}
{1705, 1701, 85, 174, 193, 263, 141, 448, 276}
Returns: -1.0
655
{1474, 1500, 2885, 2534, 2478, 2794, 2576, 2769, 2694}
{1714, 1732, 391, 253, 392, 450, 186, 341, 326}
Returns: 24.78288409190985
480
{1514, 1509, 2600, 2675, 2878, 2782, 2584, 2873, 2722}
{1699, 1688, 379, 119, 389, 283, 224, 102, 366}
Returns: 23.803968594369593
1247
{1545, 1503, 2615, 2504, 2886, 2721, 2497, 2579, 2926}
{1647, 1678, 357, 83, 240, 446, 433, 211, 109}
Returns: 28.729681693903068
2901
{1486, 1447, 2627, 2797, 2908, 2827, 2713, 2647, 2500}
{1698, 1659, 91, 186, 455, 280, 463, 93, 123}
Returns: -1.0
37
{1575, 1476, 2568, 2716, 2510, 2730, 2774, 2626, 2916}
{1710, 1692, 142, 298, 292, 367, 99, 340, 156}
Returns: 21.62493085310635
1669
{1470, 1575, 2799, 2716, 2481, 2687, 2904, 2521, 2685}
{1640, 1714, 435, 253, 301, 217, 139, 170, 108}
Returns: 32.31733026762112
840
{1528, 1472, 2953, 2854, 2918, 2849, 2643, 2663, 2852}
{1649, 1725, 491, 284, 491, 343, 98, 243, 256}
Returns: 25.902981728497977
1441
{1580, 1494, 2834, 2658, 2650, 2486, 2648, 2891, 2649}
{1729, 1649, 499, 229, 188, 141, 139, 259, 475}
Returns: 29.923263658520504
1359
{1464, 1500, 2765, 2961, 2705, 2896, 2866, 2650, 2720}
{1685, 1732, 477, 286, 309, 214, 59, 260, 429}
Returns: 29.609131167187037
72
{1531, 1469, 2735, 2539, 2540, 2574, 2769, 2763, 2485}
{1666, 1718, 174, 212, 134, 363, 162, 440, 380}
Returns: 21.783183102247648
851
{1551, 1516, 2841, 2763, 2565, 2493, 2857, 2512, 2550}
{1731, 1658, 306, 244, 140, 393, 303, 461, 302}
Returns: 25.972558302706005
2026
{1494, 1475, 2841, 2540, 2959, 2718, 2930, 2580, 2862}
{1700, 1703, 396, 460, 85, 249, 358, 392, 51}
Returns: -1.0
2458
{1501, 1585, 2568, 2612, 2671, 2928, 2861, 2769, 2531}
{1720, 1687, 395, 219, 178, 423, 302, 456, 283}
Returns: -1.0
950
{1522, 1499, 2835, 2681, 2482, 2898, 2655, 2831, 2740}
{1703, 1704, 441, 241, 232, 427, 93, 88, 91}
Returns: 26.61472958617206
1411
{1501, 1420, 2869, 2563, 2967, 2920, 2862, 2620, 2896}
{1722, 1718, 133, 201, 260, 227, 144, 155, 479}
Returns: 30.034287741826027
2861
{1478, 1499, 2668, 2822, 2953, 2943, 2485, 2695, 2812}
{1658, 1725, 293, 290, 177, 187, 292, 352, 220}
Returns: 48.23641542085916
519
{1521, 1545, 2570, 2750, 2963, 2728, 2944, 2883, 2534}
{1725, 1730, 68, 242, 376, 161, 311, 149, 413}
Returns: 24.015771472506188
678
{1489, 1497, 2627, 2696, 2705, 2835, 2772, 2839, 2613}
{1682, 1706, 122, 200, 291, 488, 340, 298, 452}
Returns: 24.917177035275017
2849
{1498, 1535, 2721, 2492, 2591, 2769, 2540, 2501, 2573}
{1732, 1703, 115, 394, 249, 404, 287, 108, 264}
Returns: -1.0
2859
{1543, 1441, 2709, 2688, 2549, 2491, 2648, 2866, 2625}
{1685, 1722, 144, 331, 250, 241, 172, 323, 206}
Returns: 47.114293288225944
499
{1508, 1535, 2932, 2946, 2850, 2809, 2526, 2505, 2873}
{1732, 1669, 283, 215, 447, 136, 251, 419, 222}
Returns: 23.906713436666493
2243
{1425, 1540, 2688, 2575, 2584, 2785, 2649, 2723, 2823}
{1686, 1656, 500, 161, 141, 171, 408, 380, 257}
Returns: 36.45054739069765
858
{1484, 1567, 2944, 2523, 2628, 2532, 2487, 2817, 2864}
{1669, 1707, 98, 451, 391, 486, 84, 81, 125}
Returns: 26.017015664393845
1438
{1468, 1517, 2769, 2931, 2501, 2752, 2690, 2547, 2737}
{1646, 1731, 186, 324, 399, 482, 162, 470, 308}
Returns: 30.259435247307067
2128
{1590, 1528, 2653, 2657, 2804, 2604, 2796, 2743, 2850}
{1730, 1707, 219, 414, 178, 303, 168, 215, 213}
Returns: 36.7704834376051
91
{1460, 1412, 2926, 2874, 2553, 2769, 2734, 2921, 2665}
{1722, 1699, 354, 449, 84, 51, 253, 110, 159}
Returns: 21.870017567612067
1486
{1537, 1476, 2751, 2682, 2784, 2510, 2781, 2704, 2742}
{1676, 1649, 98, 430, 402, 165, 371, 93, 219}
Returns: 30.66732440931191
838
{1468, 1485, 2903, 2898, 2743, 2864, 2661, 2667, 2836}
{1691, 1712, 364, 226, 412, 354, 312, 136, 185}
Returns: 25.890368709532936
2810
{1511, 1518, 2613, 2562, 2542, 2963, 2495, 2831, 2693}
{1678, 1670, 367, 473, 302, 140, 292, 98, 453}
Returns: -1.0
1098
{1493, 1453, 2917, 2820, 2483, 2955, 2779, 2946, 2765}
{1712, 1686, 239, 461, 397, 110, 358, 362, 477}
Returns: 27.631422371236447
1140
{1472, 1552, 2657, 2724, 2524, 2729, 2791, 2836, 2952}
{1686, 1695, 470, 98, 101, 460, 500, 370, 255}
Returns: 27.933100262427935
2762
{1500, 1594, 2814, 2659, 2865, 2542, 2904, 2942, 2660}
{1732, 1719, 342, 182, 71, 245, 401, 497, 470}
Returns: 45.84550797561554
35
{1460, 1525, 2541, 2757, 2949, 2957, 2921, 2746, 2581}
{1644, 1725, 284, 447, 243, 422, 490, 284, 224}
Returns: 21.61595396254762
2679
{1450, 1545, 2701, 2657, 2681, 2672, 2476, 2530, 2790}
{1687, 1690, 400, 140, 476, 250, 388, 223, 338}
Returns: 45.05791629169531
2328
{1431, 1526, 2475, 2586, 2647, 2910, 2803, 2714, 2817}
{1720, 1680, 444, 333, 198, 391, 428, 235, 56}
Returns: 39.79337934817982
152
{1500, 1487, 2728, 2491, 2621, 2825, 2642, 2955, 2904}
{1732, 1731, 143, 336, 324, 266, 208, 165, 298}
Returns: 22.15330349945802
1031
{1501, 1535, 2857, 2678, 2560, 2779, 2967, 2598, 2557}
{1724, 1655, 70, 376, 282, 272, 261, 127, 381}
Returns: 27.162423084690076
55
{1479, 1427, 2530, 2808, 2840, 2932, 2737, 2873, 2604}
{1708, 1726, 487, 471, 121, 446, 473, 266, 380}
Returns: 21.706043385046158
2628
{1548, 1485, 2725, 2519, 2813, 2883, 2620, 2836, 2647}
{1667, 1645, 204, 125, 347, 407, 391, 169, 357}
Returns: 44.22544934160531
1891
{1543, 1518, 2662, 2944, 2757, 2493, 2962, 2557, 2769}
{1697, 1698, 214, 155, 206, 53, 479, 444, 382}
Returns: 32.722652216820116
1919
{1498, 1589, 2876, 2731, 2672, 2763, 2539, 2749, 2884}
{1689, 1710, 100, 140, 319, 387, 230, 426, 313}
Returns: 34.842691883211046
623
{1588, 1496, 2567, 2691, 2867, 2635, 2511, 2958, 2523}
{1691, 1676, 76, 160, 345, 450, 205, 498, 83}
Returns: 24.59828302183631
665
{1472, 1538, 2610, 2951, 2756, 2634, 2967, 2847, 2671}
{1710, 1716, 238, 463, 318, 128, 425, 241, 52}
Returns: 24.84110535733005
1693
{1455, 1442, 2579, 2944, 2740, 2667, 2932, 2580, 2797}
{1678, 1651, 407, 63, 183, 194, 377, 494, 352}
Returns: 32.54553768877361
2199
{1504, 1466, 2655, 2722, 2795, 2887, 2614, 2762, 2886}
{1643, 1683, 271, 245, 485, 420, 326, 487, 315}
Returns: 36.53508316908163
943
{1541, 1494, 2652, 2799, 2813, 2807, 2539, 2849, 2964}
{1683, 1730, 96, 200, 420, 118, 158, 164, 463}
Returns: 26.56835772021335
1129
{1479, 1539, 2598, 2741, 2955, 2587, 2604, 2641, 2913}
{1699, 1698, 114, 209, 207, 270, 375, 492, 97}
Returns: 27.85350529829538
2767
{1521, 1469, 2707, 2651, 2923, 2511, 2778, 2734, 2852}
{1716, 1721, 450, 223, 302, 221, 410, 52, 74}
Returns: -1.0
1709
{1594, 1491, 2612, 2904, 2519, 2795, 2618, 2954, 2677}
{1706, 1703, 69, 293, 370, 233, 151, 462, 306}
Returns: 32.699275562952415
2841
{1514, 1438, 2672, 2719, 2773, 2673, 2828, 2510, 2945}
{1694, 1703, 324, 235, 249, 140, 406, 262, 256}
Returns: 46.96696076023582
393
{1497, 1562, 2678, 2611, 2690, 2518, 2482, 2656, 2633}
{1696, 1689, 364, 240, 448, 363, 485, 51, 491}
Returns: 23.343947654891466
811
{1426, 1480, 2580, 2554, 2691, 2485, 2941, 2693, 2573}
{1680, 1725, 104, 288, 379, 310, 317, 314, 236}
Returns: 25.72120594463378
1336
{1472, 1509, 2554, 2552, 2813, 2900, 2827, 2704, 2901}
{1699, 1722, 205, 335, 162, 389, 495, 201, 301}
Returns: 29.42455449702296
1334
{1527, 1513, 2509, 2505, 2873, 2893, 2707, 2857, 2585}
{1654, 1671, 338, 75, 303, 485, 254, 281, 496}
Returns: 29.408603323726766
1646
{1479, 1468, 2762, 2547, 2878, 2485, 2615, 2597, 2808}
{1729, 1697, 399, 400, 482, 271, 329, 307, 247}
Returns: 32.101295117355
1309
{1415, 1499, 2556, 2742, 2593, 2864, 2911, 2838, 2934}
{1684, 1730, 470, 239, 474, 407, 114, 88, 104}
Returns: 29.21053511716169
1664
{1537, 1527, 2819, 2488, 2874, 2550, 2620, 2793, 2600}
{1698, 1671, 257, 294, 281, 91, 432, 294, 461}
Returns: 32.27014579240081
1461
{1500, 1519, 2486, 2518, 2709, 2558, 2596, 2514, 2891}
{1732, 1654, 364, 378, 283, 493, 434, 412, 159}
Returns: 30.453650337044166
2215
{1548, 1503, 2498, 2713, 2914, 2825, 2525, 2960, 2657}
{1660, 1709, 425, 155, 292, 167, 321, 55, 356}
Returns: 37.31873142401753
1819
{1413, 1503, 2506, 2941, 2556, 2691, 2505, 2930, 2935}
{1714, 1730, 206, 469, 387, 252, 121, 295, 131}
Returns: 33.79206711472079
2699
{1434, 1483, 2947, 2742, 2552, 2652, 2645, 2715, 2685}
{1723, 1729, 355, 124, 75, 82, 324, 498, 322}
Returns: 43.12723573636204
1797
{1477, 1502, 2731, 2595, 2843, 2564, 2665, 2936, 2527}
{1680, 1673, 282, 284, 312, 241, 77, 233, 380}
Returns: 33.56838294203687
2404
{1448, 1450, 2773, 2544, 2532, 2685, 2726, 2496, 2689}
{1653, 1707, 205, 73, 273, 184, 398, 444, 240}
Returns: -1.0
579
{1510, 1447, 2527, 2572, 2540, 2894, 2715, 2737, 2877}
{1714, 1665, 176, 152, 153, 472, 293, 55, 391}
Returns: 24.3486301778553
2703
{1439, 1449, 2753, 2558, 2533, 2827, 2967, 2598, 2655}
{1708, 1694, 171, 355, 255, 234, 199, 470, 467}
Returns: 45.4582231624032
2360
{1550, 1427, 2560, 2825, 2648, 2825, 2663, 2651, 2693}
{1731, 1711, 192, 281, 239, 113, 66, 411, 214}
Returns: -1.0
845
{1543, 1439, 2540, 2773, 2583, 2726, 2759, 2584, 2501}
{1699, 1684, 415, 328, 443, 349, 323, 337, 362}
Returns: 25.93456438043377
112
{1546, 1499, 2861, 2795, 2831, 2573, 2612, 2773, 2917}
{1676, 1732, 336, 63, 105, 185, 478, 76, 60}
Returns: 21.96676149838636
2708
{1511, 1538, 2690, 2616, 2598, 2537, 2887, 2643, 2706}
{1709, 1687, 211, 342, 337, 342, 426, 166, 253}
Returns: 44.73226466129779
2818
{1530, 1481, 2664, 2491, 2951, 2774, 2837, 2759, 2532}
{1698, 1702, 225, 370, 258, 241, 438, 376, 255}
Returns: 44.59886924109083
2494
{1528, 1450, 2487, 2506, 2822, 2587, 2516, 2730, 2787}
{1689, 1684, 275, 99, 169, 259, 494, 370, 135}
Returns: 42.15130536538905
879
{1477, 1514, 2959, 2658, 2688, 2573, 2777, 2764, 2915}
{1730, 1728, 247, 409, 206, 203, 173, 335, 158}
Returns: 26.15124103849317
1293
{1572, 1483, 2873, 2705, 2880, 2873, 2636, 2965, 2479}
{1681, 1724, 95, 176, 61, 393, 285, 304, 454}
Returns: 29.085043625440115
2357
{1545, 1507, 2614, 2767, 2926, 2930, 2880, 2600, 2649}
{1677, 1672, 415, 64, 195, 405, 267, 277, 344}
Returns: 40.18937659495279
2965
{1461, 1479, 2748, 2572, 2905, 2961, 2779, 2727, 2806}
{1724, 1701, 340, 322, 191, 321, 232, 334, 199}
Returns: -1.0
1310
{1499, 1507, 2619, 2880, 2832, 2599, 2693, 2552, 2537}
{1696, 1698, 63, 344, 444, 450, 117, 361, 298}
Returns: 29.218411128774186
2820
{1442, 1503, 2678, 2523, 2586, 2886, 2652, 2957, 2726}
{1705, 1719, 276, 258, 266, 418, 355, 315, 222}
Returns: 47.49105008761407
2199
{1558, 1524, 2766, 2751, 2621, 2682, 2721, 2872, 2804}
{1725, 1721, 476, 314, 164, 252, 432, 150, 233}
Returns: 38.108521290089946
347
{1531, 1502, 2688, 2565, 2874, 2719, 2499, 2596, 2944}
{1724, 1724, 473, 498, 66, 189, 111, 172, 104}
Returns: 23.107440730927863
1423
{1459, 1498, 2784, 2663, 2901, 2650, 2750, 2869, 2656}
{1715, 1718, 274, 94, 163, 237, 66, 140, 425}
Returns: 30.13397728369089
199
{1531, 1441, 2732, 2906, 2823, 2952, 2831, 2785, 2617}
{1723, 1673, 143, 490, 74, 316, 62, 207, 403}
Returns: 22.37636975893011
1642
{1478, 1521, 2801, 2842, 2782, 2847, 2478, 2703, 2931}
{1685, 1728, 480, 296, 221, 165, 313, 308, 289}
Returns: 32.06398685211629
2969
{1554, 1524, 2966, 2506, 2943, 2849, 2548, 2884, 2659}
{1649, 1713, 100, 192, 182, 491, 125, 196, 415}
Returns: -1.0
490
{1492, 1441, 2637, 2542, 2539, 2698, 2603, 2661, 2921}
{1730, 1655, 330, 415, 151, 401, 142, 151, 197}
Returns: 23.857940942631842
74
{1484, 1571, 2663, 2939, 2761, 2849, 2720, 2537, 2938}
{1724, 1678, 75, 482, 322, 135, 254, 315, 183}
Returns: 21.792292668875902
1013
{1505, 1455, 2763, 2539, 2532, 2518, 2952, 2475, 2528}
{1721, 1653, 429, 447, 349, 129, 211, 242, 96}
Returns: 27.03892029424609
2474
{1433, 1483, 2672, 2624, 2504, 2555, 2886, 2659, 2956}
{1716, 1700, 110, 199, 195, 319, 326, 500, 427}
Returns: -1.0
2038
{1473, 1531, 2549, 2640, 2818, 2603, 2754, 2905, 2527}
{1682, 1665, 96, 185, 106, 249, 53, 68, 364}
Returns: 35.3050273265593
654
{1463, 1409, 2526, 2913, 2790, 2624, 2685, 2703, 2690}
{1723, 1719, 80, 193, 104, 321, 209, 405, 265}
Returns: 24.77707602455017
2483
{1416, 1486, 2802, 2958, 2945, 2546, 2519, 2747, 2891}
{1730, 1673, 340, 212, 202, 442, 155, 264, 212}
Returns: 41.98803448278311
2334
{1459,1396,1509,1559,1609}
{1717,1727,1717,1717,1717}
Returns: 37.569832573137546
1
{26}
{1}
Returns: -1.0
1000
{1400,1450,1500,1550,1600}
{1733,1733,1733,1733,1733}
Returns: -1.0
55
{ 1479, 1427, 2556, 2834, 2866, 2958, 2763, 2899, 2630 }
{ 1708, 1726, 487, 471, 121, 446, 473, 266, 380 }
Returns: 21.706043385046158