Submission #5102973
Source Code Expand
import sys input = sys.stdin.readline L=int(input()) A=[int(input()) for i in range(L)] SUM=[0] for a in A: SUM.append(SUM[-1]+a) def div2(x): if x==0: return 2 else: return x%2 DP0=[0]*(L+1) DP1=[0]*(L+1) DP2=[0]*(L+1) DP3=[0]*(L+1) for i in range(L): DP0[i]=DP0[i-1]+A[i] DP1[i]=min(DP0[i-1]+div2(A[i]),DP1[i-1]+div2(A[i])) DP2[i]=min(DP2[i-1]+(A[i]+1)%2,DP1[i-1]+(A[i]+1)%2) DP3[i]=min(DP3[i-1]+A[i],DP2[i-1]+A[i]) ANS=min(DP0[L-1],DP1[L-1],DP2[L-1],DP3[L-1]) DP0=[0]*(L+1) DP1=[0]*(L+1) DP2=[0]*(L+1) DP3=[0]*(L+1) for i in range(L): DP0[i]=DP0[i-1]+A[i] DP1[i]=min(DP0[i-1]+(A[i]+1)%2,DP1[i-1]+(A[i]+1)%2) DP2[i]=min(DP2[i-1]+div2(A[i]),DP1[i-1]+div2(A[i])) DP3[i]=min(DP3[i-1]+A[i],DP2[i-1]+A[i]) ANS=min(DP0[L-1],DP1[L-1],DP2[L-1],DP3[L-1],ANS) print(ANS)
Submission Info
Submission Time | |
---|---|
Task | D - Ears |
User | titia |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 896 Byte |
Status | WA |
Exec Time | 1250 ms |
Memory | 55316 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 600 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 1125 ms | 55276 KB |
02.txt | WA | 1101 ms | 55304 KB |
03.txt | WA | 1043 ms | 55288 KB |
04.txt | WA | 1073 ms | 55316 KB |
05.txt | AC | 1042 ms | 45800 KB |
06.txt | AC | 1032 ms | 45800 KB |
07.txt | AC | 1067 ms | 45708 KB |
08.txt | AC | 1106 ms | 45792 KB |
09.txt | WA | 1059 ms | 45772 KB |
10.txt | WA | 1083 ms | 45708 KB |
11.txt | WA | 1061 ms | 45696 KB |
12.txt | WA | 1250 ms | 45724 KB |
13.txt | WA | 1052 ms | 45728 KB |
14.txt | WA | 1069 ms | 45712 KB |
15.txt | WA | 1114 ms | 45776 KB |
16.txt | WA | 1029 ms | 45744 KB |
17.txt | WA | 1004 ms | 36016 KB |
18.txt | WA | 915 ms | 18680 KB |
19.txt | WA | 1045 ms | 27468 KB |
20.txt | WA | 1002 ms | 41692 KB |
21.txt | AC | 900 ms | 14260 KB |
22.txt | AC | 909 ms | 14256 KB |
23.txt | AC | 1036 ms | 33068 KB |
24.txt | AC | 1013 ms | 31436 KB |
25.txt | AC | 1066 ms | 33064 KB |
26.txt | AC | 1089 ms | 47300 KB |
27.txt | WA | 1097 ms | 45720 KB |
28.txt | AC | 1070 ms | 45736 KB |
29.txt | AC | 1012 ms | 49000 KB |
30.txt | WA | 1012 ms | 50460 KB |
31.txt | AC | 1016 ms | 47132 KB |
32.txt | AC | 1123 ms | 50584 KB |
33.txt | WA | 1077 ms | 31852 KB |
34.txt | WA | 991 ms | 25768 KB |
35.txt | WA | 1051 ms | 30120 KB |
36.txt | WA | 943 ms | 40004 KB |
37.txt | WA | 18 ms | 3188 KB |
38.txt | WA | 18 ms | 3188 KB |
39.txt | AC | 17 ms | 3192 KB |
40.txt | AC | 17 ms | 3192 KB |
41.txt | AC | 17 ms | 3192 KB |
42.txt | AC | 17 ms | 3192 KB |
s1.txt | AC | 17 ms | 3188 KB |
s2.txt | AC | 17 ms | 3192 KB |
s3.txt | AC | 17 ms | 3192 KB |