Submission #8313152


Source Code Expand

n = int(input())
l = []
for i in range(2*n):
    c,a = input().split()
    a = int(a)
    if c == "W":
        a += n
    l.append(a)

pos = [1,n,n+1,2*n]

ans = 0
while l:
    cost = []
    if pos[0] <= pos[1]:
        i = l.index(pos[0])
        cost.append((i,i, 0))
        i = l.index(pos[1])
        cost.append((len(l)-i-1,i, 1))
    if pos[2] <= pos[3]:
        i = l.index(pos[2])
        cost.append((i,i, 2))
        i = l.index(pos[3])
        cost.append((len(l)-i-1,i, 3))
    cost.sort()
    c,i,ind = cost[0]
    ans += c
    l.pop(i)
    if ind%2:
        pos[ind] -= 1
    else:
        pos[ind] += 1

print(ans)

Submission Info

Submission Time
Task E - Sorted and Sorted
User tomboftime
Language PyPy3 (2.4.0)
Score 0
Code Size 663 Byte
Status WA
Exec Time 292 ms
Memory 44396 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 2
WA × 1
AC × 20
WA × 16
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt
Case Name Status Exec Time Memory
0_000.txt AC 167 ms 38384 KB
0_001.txt AC 166 ms 38256 KB
0_002.txt WA 169 ms 38256 KB
1_003.txt AC 169 ms 38256 KB
1_004.txt AC 162 ms 38256 KB
1_005.txt AC 164 ms 38256 KB
1_006.txt AC 165 ms 38256 KB
1_007.txt AC 171 ms 38384 KB
1_008.txt WA 168 ms 38256 KB
1_009.txt AC 165 ms 38256 KB
1_010.txt AC 166 ms 38256 KB
1_011.txt AC 172 ms 38256 KB
1_012.txt AC 176 ms 38256 KB
1_013.txt AC 169 ms 38256 KB
1_014.txt WA 280 ms 44268 KB
1_015.txt WA 254 ms 43244 KB
1_016.txt WA 271 ms 43500 KB
1_017.txt WA 266 ms 43628 KB
1_018.txt WA 176 ms 38256 KB
1_019.txt WA 247 ms 42348 KB
1_020.txt WA 279 ms 43884 KB
1_021.txt AC 264 ms 42476 KB
1_022.txt AC 243 ms 42476 KB
1_023.txt AC 259 ms 43372 KB
1_024.txt AC 276 ms 44140 KB
1_025.txt WA 278 ms 43884 KB
1_026.txt WA 283 ms 43884 KB
1_027.txt WA 283 ms 44012 KB
1_028.txt WA 281 ms 44396 KB
1_029.txt WA 286 ms 44268 KB
1_030.txt WA 273 ms 43884 KB
1_031.txt WA 285 ms 44012 KB
1_032.txt AC 292 ms 43884 KB
1_033.txt AC 283 ms 43884 KB
1_034.txt AC 273 ms 43500 KB
1_035.txt AC 283 ms 44268 KB