Submission #3780680
Source Code Expand
n=int(input()) a=[int(i) for i in input().split()] o,e=[],[] for i in range(n): if i%2: e.append(a[i]) o.append(0) else: o.append(a[i]) e.append(0) if min(a)<0: ans=min(a)*n else: ans=0 for i in range(n): chk=[0]*3 for j in range(n): if i==j: continue elif i<j: 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] elif i>j: 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 | 100 |
Code Size | 1049 Byte |
Status | AC |
Exec Time | 193 ms |
Memory | 40944 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 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 | AC | 161 ms | 38256 KB |
sample-02.txt | AC | 159 ms | 38256 KB |
sample-03.txt | AC | 161 ms | 38256 KB |
test-01.txt | AC | 163 ms | 38256 KB |
test-02.txt | AC | 170 ms | 38512 KB |
test-03.txt | AC | 169 ms | 38512 KB |
test-04.txt | AC | 173 ms | 38896 KB |
test-05.txt | AC | 192 ms | 40304 KB |
test-06.txt | AC | 187 ms | 40304 KB |
test-07.txt | AC | 188 ms | 40816 KB |
test-08.txt | AC | 189 ms | 40816 KB |
test-09.txt | AC | 189 ms | 40816 KB |
test-10.txt | AC | 193 ms | 40816 KB |
test-11.txt | AC | 190 ms | 40944 KB |
test-12.txt | AC | 189 ms | 40816 KB |
test-13.txt | AC | 187 ms | 40816 KB |
test-14.txt | AC | 191 ms | 40816 KB |
test-15.txt | AC | 191 ms | 40944 KB |
test-16.txt | AC | 189 ms | 40816 KB |
test-17.txt | AC | 187 ms | 40816 KB |
test-18.txt | AC | 188 ms | 40816 KB |
test-19.txt | AC | 190 ms | 40816 KB |
test-20.txt | AC | 190 ms | 40944 KB |