We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3eedc0e commit c4c4c35Copy full SHA for c4c4c35
1901A Line Trip.cpp
@@ -0,0 +1,49 @@
1
+#include <iostream>
2
+using namespace std;
3
+int main()
4
+{
5
+ int t;
6
+ cin >> t;
7
+ while (t--)
8
+ {
9
+ int n, x;
10
+ cin >> n >> x;
11
+ if (n == 1)
12
13
+ int a;
14
+ cin >> a;
15
+ if (a > 2 * (x - a))
16
17
+ cout << a << endl;
18
+ }
19
+ else
20
21
+ cout << 2 * (x - a) << endl;
22
23
24
25
26
+ int maks = -1;
27
+ int arr[n + 1];
28
+ arr[0] = 0;
29
+ for (int i = 1; i < n + 1; i++)
30
31
+ cin >> arr[i];
32
33
+ int last = arr[n];
34
+ for (int i = 0; i < n; i++)
35
36
+ if (arr[i + 1] - arr[i] > maks)
37
38
+ maks = arr[i + 1] - arr[i];
39
40
41
+ if (2 * (x - last) > maks)
42
43
+ maks = 2 * (x - last);
44
45
+ cout << maks << endl;
46
47
48
+ return 0;
49
+}
0 commit comments