Submission #3780625
Source Code Expand
n=int(input()) a=[int(i) for i in input().split()] o,e=[],[] ot,et=[0]*n,[0]*n for i in range(n): if i%2: e.append(a[i]) o.append(0) else: o.append(a[i]) e.append(0) if i==0: ot[0]=o[0] et[0]=e[0] else: ot[i]=ot[i-1]+o[i] et[i]=et[i-1]+e[i] if min(a)<0: ans=min(a)*n else: ans=0 for i in range(n-1): chk=[0]*3 for j in range(i+1,n): if i%2: t=sum(e[i:j+1]) b=sum(o[i:j+1]) if chk[2]==0 or b>chk[1]: chk=[t,b,1] else: t=sum(o[i:j+1]) b=sum(e[i:j+1]) if chk[2]==0 or b>chk[1]: chk=[t,b,1] ans=max(ans,chk[0]) for i in range(1,n): chk=[0]*3 for j in range(i): if j%2: t=sum(e[j:i+1]) b=sum(o[j:i+1]) if chk[2]==0 or b>chk[1]: chk=[t,b,1] else: t=sum(o[j:i+1]) b=sum(e[j:i+1]) if chk[2]==0 or b>chk[1]: chk=[t,b,1] ans=max(ans,chk[0]) print(ans)
Submission Info
Submission Time | |
---|---|
Task | C - 数列ゲーム |
User | nyon |
Language | PyPy3 (2.4.0) |
Score | 0 |
Code Size | 1146 Byte |
Status | WA |
Exec Time | 210 ms |
Memory | 40560 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt |
All | sample-01.txt, sample-02.txt, sample-03.txt, test-01.txt, test-02.txt, test-03.txt, test-04.txt, test-05.txt, test-06.txt, test-07.txt, test-08.txt, test-09.txt, test-10.txt, test-11.txt, test-12.txt, test-13.txt, test-14.txt, test-15.txt, test-16.txt, test-17.txt, test-18.txt, test-19.txt, test-20.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample-01.txt | WA | 169 ms | 38256 KB |
sample-02.txt | AC | 168 ms | 38256 KB |
sample-03.txt | WA | 168 ms | 38256 KB |
test-01.txt | WA | 169 ms | 38256 KB |
test-02.txt | AC | 173 ms | 38512 KB |
test-03.txt | WA | 172 ms | 38512 KB |
test-04.txt | WA | 187 ms | 39024 KB |
test-05.txt | AC | 177 ms | 38768 KB |
test-06.txt | WA | 181 ms | 38768 KB |
test-07.txt | WA | 198 ms | 40560 KB |
test-08.txt | AC | 198 ms | 40432 KB |
test-09.txt | WA | 195 ms | 40432 KB |
test-10.txt | WA | 197 ms | 40432 KB |
test-11.txt | AC | 198 ms | 40432 KB |
test-12.txt | WA | 201 ms | 40432 KB |
test-13.txt | WA | 210 ms | 40432 KB |
test-14.txt | AC | 197 ms | 40560 KB |
test-15.txt | WA | 198 ms | 40432 KB |
test-16.txt | WA | 197 ms | 40560 KB |
test-17.txt | AC | 197 ms | 40432 KB |
test-18.txt | AC | 199 ms | 40432 KB |
test-19.txt | AC | 195 ms | 40432 KB |
test-20.txt | WA | 201 ms | 40432 KB |