Submission #2694717


Source Code Expand

from itertools import accumulate, chain
 
n, c = map(int, input().split())
xs, vs = zip(*(map(int, input().split()) for _ in range(n)))
 
ds = [j - i for i, j in zip(chain([0], xs), chain(xs, [c]))]
 
clockwise1      = chain([0], (v - d*2 for v, d in zip(accumulate(vs), accumulate(ds))))
anticlockwise1  = chain([0], (v - d for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))))
clock_anticlock = (x + y for x, y in zip(clockwise1, reversed(list(accumulate(anticlockwise1, func=max)))))
 
anticlockwise2  = chain([0], (v - d*2 for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))))
clockwise2      = chain([0], (v - d for v, d in zip(accumulate(vs), accumulate(ds))))
anticlock_clock = (x + y for x, y in zip(anticlockwise2, reversed(list(accumulate(clockwise2, func=max)))))
 
print(max(chain(clock_anticlock, anticlock_clock)))

Submission Info

Submission Time
Task D - Static Sushi
User zehnpaard
Language Python (3.4.3)
Score 500
Code Size 859 Byte
Status AC
Exec Time 556 ms
Memory 59224 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 300 / 300 200 / 200
Status
AC × 4
AC × 29
AC × 50
Set Name Test Cases
Sample a01, a02, a03, a04
Subtask1 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29
Subtask2 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50
Case Name Status Exec Time Memory
a01 AC 17 ms 3064 KB
a02 AC 17 ms 3064 KB
a03 AC 17 ms 3064 KB
a04 AC 17 ms 3064 KB
b05 AC 17 ms 3064 KB
b06 AC 17 ms 3064 KB
b07 AC 17 ms 3064 KB
b08 AC 17 ms 3064 KB
b09 AC 18 ms 3064 KB
b10 AC 18 ms 3064 KB
b11 AC 18 ms 3064 KB
b12 AC 18 ms 3064 KB
b13 AC 18 ms 3064 KB
b14 AC 18 ms 3064 KB
b15 AC 18 ms 3064 KB
b16 AC 18 ms 3064 KB
b17 AC 18 ms 3064 KB
b18 AC 18 ms 3064 KB
b19 AC 18 ms 3064 KB
b20 AC 18 ms 3064 KB
b21 AC 18 ms 3064 KB
b22 AC 18 ms 3064 KB
b23 AC 18 ms 3064 KB
b24 AC 18 ms 3064 KB
b25 AC 18 ms 3064 KB
b26 AC 18 ms 3064 KB
b27 AC 18 ms 3064 KB
b28 AC 18 ms 3064 KB
b29 AC 18 ms 3064 KB
c30 AC 502 ms 48768 KB
c31 AC 532 ms 58328 KB
c32 AC 556 ms 59224 KB
c33 AC 545 ms 59224 KB
c34 AC 540 ms 59224 KB
c35 AC 492 ms 48768 KB
c36 AC 522 ms 59220 KB
c37 AC 536 ms 59092 KB
c38 AC 544 ms 59096 KB
c39 AC 529 ms 59096 KB
c40 AC 541 ms 59096 KB
c41 AC 536 ms 58968 KB
c42 AC 539 ms 59096 KB
c43 AC 60 ms 8692 KB
c44 AC 525 ms 59224 KB
c45 AC 22 ms 3572 KB
c46 AC 533 ms 59096 KB
c47 AC 18 ms 3064 KB
c48 AC 537 ms 59096 KB
c49 AC 543 ms 59096 KB
c50 AC 525 ms 59096 KB