回答編集履歴
2
2
test
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
<?php
|
4
4
|
|
5
|
+
$number = intval(trim(fgets(STDIN)));
|
6
|
+
|
5
7
|
$num = [];
|
6
|
-
|
7
|
-
$number = intval(trim(fgets(STDIN)));
|
8
8
|
|
9
9
|
for($i=0; $i<$number; $i++) {
|
10
10
|
|
1
1
test
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
<?php
|
4
4
|
|
5
5
|
$num = [];
|
6
|
-
|
7
|
-
$abs = [];
|
8
6
|
|
9
7
|
$number = intval(trim(fgets(STDIN)));
|
10
8
|
|
@@ -14,13 +12,15 @@
|
|
14
12
|
|
15
13
|
}
|
16
14
|
|
15
|
+
$abs = 1;
|
16
|
+
|
17
17
|
for($i=1; $i<count($num); $i++) {
|
18
18
|
|
19
|
-
$abs
|
19
|
+
$abs += abs($num[i] - $num[i-1]);
|
20
20
|
|
21
21
|
}
|
22
22
|
|
23
|
-
|
23
|
+
echo $abs;
|
24
24
|
|
25
25
|
?>
|
26
26
|
|