Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
p = [(int(x)+1)/2 for x in input().split()]

result = []
sub_total = sum(p[0:K])
result.append(sub_total)

for i in range(1, N-K+1):
    sub_total = sub_total - p[i-1] + p[i+K-1]
    result.append(sub_total)

print(max(result))

Buggy submission (verdict: Runtime Error):
1526.72
1526.8
1526.88
1526.96
1527.04
1527.1200000000001
1527.2
1527.28
1527.3600000000001
1527.44
1527.52
1527.6000000000001
1527.68
1527.76
1527.84
1527.92
1528.0
1528.08
1528.16
1528.24
1528.32
1528.4
1528.48
1528.56
1528.64
1528.72
1528.8
1528.88
1528.96
1529.04
1529.1200000000001
1529.2
1529.28
1529.3600000000001
1529.44
1529.52
1529.6000000000001
1529.68
1529.76
1529.8400000000001
1529.92
1530.0
1530.08
1530.16
1530.24
1530.32
1530.4
1530.48
1530.56
1530.64
1530.72
1530.8
1530.88
1530.96
1531.04
1531.1200000000001
1531.2
1531.28
1531.3600000000001
1531.44
1531.52
1531.6000000000001
1531.68
1531.76
1531.8400000000001
1531.92
1532.0
1532.08
1532.16
1532.24
1532.32
1532.4
1532.48
1532.56
1532.64
1532.72
1532.8
1532.88
1532.96
1533.04
1533.1200000000001
1533.2
1533.28
1533.3600000000001
1533.44
1533.52
1533.6000000000001
1533.68
1533.76
1533.8400000000001
1533.92
1534.0
1534.08
1534.16
1534.24
1534.32
1534.4
1534.48
1534.56
1534.64
1534.72
1534.8
1534.88
1534.96
1535.04
1535.1200000000001
1535.2
1535.28
1535.3600000000001
1535.44
1535.52
1535.6000000000001
1535.68
1535.76
1535.8400000000001
1535.92
1536.0
1536.08
1536.16
1536.24
1536.32
1536.4
1536.48
1536.56
1536.64
1536.72
1536.8
1536.88
1536.96
1537.04
1537.1200000000001
1537.2
1537.28
1537.3600000000001
1537.44
1537.52
1537.6000000000001
1537.68
1537.76
1537.8400000000001
1537.92
1538.0
1538.08
1538.16
1538.24
1538.32
1538.4
1538.48
1538.56
1538.64
1538.72
1538.8
1538.88
1538.96
1539.04
1539.1200000000001
1539.2
1539.28
1539.3600000000001
1539.44
1539.52
1539.6000000000001
1539.68
1539.76
1539.8400000000001
1539.92
1540.0
1540.08
1540.16
1540.24
1540.32
1540.4
1540.48
1540.56
1540.64
1540.72
1540.8
1540.88
1540.96
1541.04
1541.1200000000001
1541.2
1541.28
1541.3600000000001
1541.44
1541.52
1541.6000000000001
1541.68
1541.76
1541.8400000000001
1541.92
1542.0
1542.08
1542.16
1542.24
1542.32
1542.4
1542.48
1542.56
1542.64
1542.72
1542.8
1542.88
1542.96
1543.04
1543.1200000000001
1543.2
1543.28
1543.3600000000001
1543.44
1543.52
1543.6000000000001
1543.68
1543.76
1543.8400000000001
1543.92
1544.0
1544.08
1544.16
1544.24
1544.32
1544.4
1544.48
1544.56
1544.64
1544.72
1544.8
1544.88
1544.96
1545.04
1545.1200000000001
1545.2
1545.28
1545.3600000000001
1545.44
1545.52
1545.6000000000001
1545.68
1545.76
1545.8400000000001
1545.92
1546.0
1546.08
1546.16
1546.24
1546.32
1546.4
1546.48
1546.56
1546.64
1546.72
1546.8
1546.88
1546.96
1547.04
1547.1200000000001
1547.2
1547.28
1547.3600000000001
1547.44
1547.52
1547.6000000000001
1547.68
1547.76
1547.8400000000001
1547.92
1548.0
1548.08
1548.16
1548.24
1548.32
1548.4
1548.48
1548.56
1548.64
1548.72
1548.8
1548.88
1548.96
1549.04
1549.1200000000001
1549.2
1549.28
1549.3600000000001
1549.44
1549.52
1549.6000000000001
1549.68
1549.76
1549.8400000000001
1549.92
1550.0
1550.08
1550.16
1550.24
1550.32
1550.4
1550.48
1550.56
1550.64
1550.72
1550.8
1550.88
1550.96
1551.04
1551.1200000000001
1551.2
1551.28
1551.3600000000001
1551.44
1551.52
1551.6000000000001
1551.68
1551.76
1551.8400000000001
1551.92
1552.0
1552.08
1552.16
1552.24
1552.32
1552.4
1552.48
1552.56
1552.64
1552.72
1552.8
1552.88
1552.96
1553.04
1553.1200000000001
1553.2
1553.28
1553.3600000000001
1553.44
1553.52
1553.6000000000001
1553.68
1553.76
1553.8400000000001
1553.92
1554.0
1554.08
1554.16
1554.24
1554.32
1554.4
1554.48
1554.56
1554.64
1554.72
1554.8
1554.88
1554.96
1555.04
1555.1200000000001
1555.2
1555.28
1555.3600000000001
1555.44
1555.52
1555.6000000000001
1555.68
1555.76
1555.8400000000001
1555.92
1556.0
1556.08
1556.16
1556.24
1556.32
1556.4
1556.48
1556.56
1556.64
1556.72
1556.8
1556.88
1556.96
1557.04
1557.1200000000001
1557.2
1557.28
1557.3600000000001
1557.44
1557.52
1557.6000000000001
1557.68
1557.76
1557.8400000000001
1557.92
1558.0
1558.08
1558.16
1558.24
1558.32
1558.4
1558.48
1558.56
1558.64
1558.72
1558.8
1558.88
1558.96
1559.04
1559.1200000000001
1559.2
1559.28
1559.3600000000001
1559.44
1559.52
1559.6000000000001
1559.68
1559.76
1559.8400000000001
1559.92
1560.0
1560.08
1560.16
1560.24
1560.32
1560.4
1560.48
1560.56
1560.64
1560.72
1560.8
1560.88
1560.96
1561.04
1561.1200000000001
1561.2
1561.28
1561.3600000000001
1561.44
1561.52
1561.6000000000001
1561.68
1561.76
1561.8400000000001
1561.92
1562.0
1562.08
1562.16
1562.24
1562.32
1562.4
1562.48
1562.56
1562.64
1562.72
1562.8
1562.88
1562.96
1563.04
1563.1200000000001
1563.2
1563.28
1563.3600000000001
1563.44
1563.52
1563.6000000000001
1563.68
1563.76
1563.8400000000001
1563.92
1564.0
1564.08
1564.16
1564.24
1564.32
1564.4
1564.48
1564.56
1564.64
1564.72
1564.8
1564.88
1564.96
1565.04
1565.1200000000001
1565.2
1565.28
1565.3600000000001
1565.44
1565.52
1565.6000000000001
1565.68
1565.76
1565.8400000000001
1565.92
1566.0
1566.08
1566.16
1566.24
1566.32
1566.4
1566.48
1566.56
1566.64
1566.72
1566.8
1566.88
1566.96
1567.04
1567.1200000000001
1567.2
1567.28
1567.3600000000001
1567.44
1567.52
1567.6000000000001
1567.68
1567.76
1567.8400000000001
1567.92
1568.0
1568.08
1568.16
1568.24
1568.32
1568.4
1568.48
1568.56
1568.64
1568.72
1568.8
1568.88
1568.96
1569.04
1569.1200000000001
1569.2
1569.28
1569.3600000000001
1569.44
1569.52
1569.6000000000001
1569.68
1569.76
1569.8400000000001
1569.92
1570.0
1570.08
1570.16
1570.24
1570.32
1570.4
1570.48
1570.56
1570.64
1570.72
1570.8
1570.88
1570.96
1571.04
1571.1200000000001
1571.2
1571.28
1571.3600000000001
1571.44
1571.52
1571.6000000000001
1571.68
1571.76
1571.8400000000001
1571.92
1572.0
1572.08
1572.16
1572.24
1572.32
1572.4
1572.48
1572.56
1572.64
1572.72
1572.8
1572.88
1572.96
1573.04
1573.1200000000001
1573.2
1573.28
1573.3600000000001
1573.44
1573.52
1573.6000000000001
1573.68
1573.76
1573.8400000000001
1573.92
1574.0
1574.08
1574.16
1574.24
1574.32
1574.4
1574.48
1574.56
1574.64
1574.72
1574.8
1574.88
1574.96
1575.04
1575.1200000000001
1575.2
1575.28
1575.3600000000001
1575.44
1575.52
1575.6000000000001
1575.68
1575.76
1575.8400000000001
1575.92
1576.0
1576.08
1576.16
1576.24
1576.32
1576.4
1576.48
1576.56
1576.64
1576.72
1576.8
1576.88
1576.96
1577.04
1577.1200000000001
1577.2
1577.28
1577.3600000000001
1577.44
1577.52
1577.6000000000001
1577.68
1577.76
1577.8400000000001
1577.92
1578.0
1578.08
1578.16
1578.24
1578.32
1578.4
1578.48
1578.56
1578.64
1578.72
1578.8
1578.88
1578.96
1579.04
1579.1200000000001
1579.2
1579.28
1579.3600000000001
1579.44
1579.52
1579.6000000000001
1579.68
1579.76
1579.8400000000001
1579.92
1580.0
1580.08
1580.16
1580.24
1580.32
1580.4
1580.48
1580.56
1580.64
1580.72
1580.8
1580.88
1580.96
1581.04
1581.1200000000001
1581.2
1581.28
1581.3600000000001
1581.44
1581.52
1581.6000000000001
1581.68
1581.76
1581.8400000000001
1581.92
1582.0
1582.08
1582.16
1582.24
1582.32
1582.4
1582.48
1582.56
1582.64
1582.72
1582.8
1582.88
1582.96
1583.04
1583.1200000000001
1583.2
1583.28
1583.3600000000001
1583.44
1583.52
1583.6000000000001
1583.68
1583.76
1583.8400000000001
1583.92
1584.0
1584.08
1584.16
1584.24
1584.32
1584.4
1584.48
1584.56
1584.64
1584.72
1584.8
1584.88
1584.96
1585.04
1585.1200000000001
1585.2
1585.28
1585.3600000000001
1585.44
1585.52
1585.6000000000001
1585.68
1585.76
1585.8400000000001
1585.92
1586.0
1586.08
1586.16
1586.24
1586.32
1586.4
1586.48
1586.56
1586.64
1586.72
1586.8
1586.88
1586.96
1587.04
1587.1200000000001
1587.2
1587.28
1587.3600000000001
1587.44
1587.52
1587.6000000000001
1587.68
1587.76
1587.8400000000001
1587.92
1588.0
1588.08
1588.16
1588.24
1588.32
1588.4
1588.48
1588.56
1588.64
1588.72
1588.8
1588.88
1588.96
1589.04
1589.1200000000001
1589.2
1589.28
1589.3600000000001
1589.44
1589.52
1589.6000000000001
1589.68
1589.76
1589.8400000000001
1589.92
1590.0
1590.08
1590.16
1590.24
1590.32
1590.4
1590.48
1590.56
1590.64
1590.72
1590.8
1590.88
1590.96
1591.04
1591.1200000000001
1591.2
1591.28
1591.3600000000001
1591.44
1591.52
1591.6000000000001
1591.68
1591.76
1591.8400000000001
1591.92
1592.0
1592.08
1592.16
1592.24
1592.32
1592.4
1592.48
1592.56
1592.64
1592.72
1592.8
1592.88
1592.96
1593.04
1593.1200000000001
1593.2
1593.28
1593.3600000000001
1593.44
1593.52
1593.6000000000001
1593.68
1593.76
1593.8400000000001
1593.92
1594.0
1594.08
1594.16
1594.24
1594.32
1594.4
1594.48
1594.56
1594.64
1594.72
1594.8
1594.88
1594.96
1595.04
1595.1200000000001
1595.2
1595.28
1595.3600000000001
1595.44
1595.52
1595.6000000000001
1595.68
1595.76
1595.8400000000001
1595.92
1596.0
1596.08
1596.16
1596.24
1596.32
1596.4
1596.48
1596.56
1596.64
1596.72
1596.8
1596.88
1596.96
1597.04
1597.1200000000001
1597.2
1597.28
1597.3600000000001
1597.44
1597.52
1597.6000000000001
1597.68
1597.76
1597.8400000000001
1597.92
1598.0
1598.08
1598.16
1598.24
1598.32
1598.4
1598.48
1598.56
1598.64
1598.72
1598.8
1598.88
1598.96
1599.04
1599.1200000000001
1599.2
1599.28
1599.3600000000001
1599.44
1599.52
1599.6000000000001
1599.68
1599.76
1599.8400000000001
1599.92
-1
(base) YonoMac-mini:158 yo-castle$ 
(base) YonoMac-mini:158 yo-castle$ 
(base) YonoMac-mini:158 yo-castle$ cd ..
(base) YonoMac-mini:AtCoder_Problems yo-castle$ mkdir 142
(base) YonoMac-mini:AtCoder_Problems yo-castle$ cd 142
(base) YonoMac-mini:142 yo-castle$ ll
(base) YonoMac-mini:142 yo-castle$ ll
(base) YonoMac-mini:142 yo-castle$ touch c.py
(base) YonoMac-mini:142 yo-castle$ touch input.txt
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ open c.py 
(base) YonoMac-mini:142 yo-castle$ open input.txt 
(base) YonoMac-mini:142 yo-castle$ aa
bash: aa: command not found
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ 
(base) YonoMac-mini:142 yo-castle$ python c.py < input.txt 
Traceback (most recent call last):
  File "c.py", line 12, in <module>
    print(" ".join(answer))
TypeError: sequence item 0: expected str instance, int found
(base) YonoMac-mini:142 yo-castle$ python c.py < input.txt 
3 1 2
(base) YonoMac-mini:142 yo-castle$ python c.py < input.txt 
1 2 3 4 5
(base) YonoMac-mini:142 yo-castle$ python c.py < input.txt 
8 2 4 5 6 7 3 1
(base) YonoMac-mini:142 yo-castle$ cd ..
(base) YonoMac-mini:AtCoder_Problems yo-castle$ cd 154
(base) YonoMac-mini:154 yo-castle$ ll
total 16
-rw-r--r--@ 1 yo-castle  staff  191  4 19 07:23 c.py
-rw-r--r--@ 1 yo-castle  staff   19  4 19 07:24 input.txt
(base) YonoMac-mini:154 yo-castle$ touch d.py
(base) YonoMac-mini:154 yo-castle$ ll
total 16
-rw-r--r--@ 1 yo-castle  staff  191  4 19 07:23 c.py
-rw-r--r--  1 yo-castle  staff    0  4 19 07:39 d.py
-rw-r--r--@ 1 yo-castle  staff   19  4 19 07:24 input.txt
(base) YonoMac-mini:154 yo-castle$ open d.py 
(base) YonoMac-mini:154 yo-castle$ open input.txt 
(base) YonoMac-mini:154 yo-castle$ 
(base) YonoMac-mini:154 yo-castle$ 
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
Traceback (most recent call last):
  File "d.py", line 1, in <module>
    N, K = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
Traceback (most recent call last):
  File "d.py", line 10, in <module>
    print(max(total))
TypeError: 'float' object is not iterable
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
Traceback (most recent call last):
  File "d.py", line 10, in <module>
    print(max(total))
TypeError: 'int' object is not iterable
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[1.0, 1.5, 1.5, 2.5, 3.0]
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[1.0, 1.5, 1.5, 2.5, 3.0]
[4.0, 5.5]
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[1.0, 1.5, 1.5, 2.5, 3.0]
[4.0, 5.5, 7.0]
7.0
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[3.5, 3.5, 3.5, 3.5]
[3.5, 3.5]
3.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[9.0, 7.0, 7.0, 6.5, 8.0, 10.5, 5.5, 7.0, 9.0, 6.0]
Traceback (most recent call last):
  File "d.py", line 9, in <module>
    total += p[i+j]
IndexError: list index out of range
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[9.0, 7.0, 7.0, 6.5, 8.0, 10.5, 5.5, 7.0, 9.0, 6.0]
[29.5, 28.5, 32.0, 30.5, 31.0, 32.0, 27.5]
32.0
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
Traceback (most recent call last):
  File "d.py", line 10, in <module>
    result.append(total)
NameError: name 'total' is not defined
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
25.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
Traceback (most recent call last):
  File "d.py", line 9, in <module>
    sub_total = sub_total - p[i-1] + p[i+K-1]
IndexError: list index out of range
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
[2.5, 4.0, 5.5]
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
2.5
[2.5, 4.0, 5.5]
5.5
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
4.0
[4.0, 5.5, 7.0]
7.0
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
3.5
[3.5, 3.5, 3.5, 3.5]
3.5
(base) YonoMac-mini:154 yo-castle$ [
bash: [: missing `]'
(base) YonoMac-mini:154 yo-castle$ [
bash: [: missing `]'
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
29.5
[29.5, 28.5, 32.0, 30.5, 31.0, 32.0, 27.5]
32.0
(base) YonoMac-mini:154 yo-castle$ python d.py < input.txt 
32.0
(base) YonoMac-mini:154 yo-castle$