Submission #3007346
Source Code Expand
n = int(input()) s = input() res = [] count = 0 if s[0] == '1':one = 1 else:one = 0 temp = [] tar = 0 for i in range(1,n-1): if s[i-1:i+2] == '101': # 碰到了101 tar = 1 temp.append(one) one = 0 # 任务重新计数 else: if s[i] == '0' and tar == 1: # 在任务中碰到了连续0,结束任务 temp.append(one) res.append(temp.copy()) temp = [] tar = 0 if s[i] == '1':one += 1 else: one = 0 if s[-1] == '1':one+=1 if tar == 1: temp.append(one) res.append(temp.copy()) for x in res: temp = 0 m = len(x) f = [] if m == 2:temp = max(x[0],x[1]) if m == 3:temp = max(x[0],x[1],x[2]) if m == 4:temp = max(x[0]+x[2],x[3]+max(x[0],x[1])) if m >= 5: f.append([x[0],x[1]]) f.append([x[1],max(x[2],x[0])]) f.append([x[0]+x[2],x[3]+max(x[0],x[1])]) for i in range(3,m-1): f.append([x[i] + max(f[i-2][0],f[i-3][0]),x[i+1] + max(f[i-2][0],f[i-2][1])]) temp = max(f[-1][0],f[-1][1],f[-2][0]) count += temp print(count)
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | Indeedtest0791 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1179 Byte |
Status | WA |
Exec Time | 317 ms |
Memory | 6940 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 137 ms | 3704 KB |
001.txt | WA | 90 ms | 3568 KB |
002.txt | WA | 129 ms | 4128 KB |
003.txt | WA | 91 ms | 3812 KB |
004.txt | WA | 114 ms | 4380 KB |
005.txt | WA | 155 ms | 4764 KB |
006.txt | WA | 46 ms | 3316 KB |
007.txt | WA | 87 ms | 3572 KB |
008.txt | WA | 22 ms | 3188 KB |
009.txt | WA | 186 ms | 3968 KB |
010.txt | AC | 257 ms | 4224 KB |
011.txt | WA | 257 ms | 4232 KB |
012.txt | WA | 252 ms | 4884 KB |
013.txt | WA | 285 ms | 5780 KB |
014.txt | WA | 270 ms | 6684 KB |
015.txt | WA | 285 ms | 6940 KB |
016.txt | WA | 315 ms | 6676 KB |
017.txt | WA | 317 ms | 6036 KB |
018.txt | WA | 316 ms | 5140 KB |
019.txt | WA | 260 ms | 4224 KB |
020.txt | AC | 259 ms | 4224 KB |
021.txt | AC | 242 ms | 4232 KB |
022.txt | WA | 263 ms | 4224 KB |
023.txt | WA | 266 ms | 4232 KB |
024.txt | WA | 241 ms | 4224 KB |
025.txt | WA | 225 ms | 4224 KB |
026.txt | WA | 261 ms | 4232 KB |
027.txt | WA | 290 ms | 4224 KB |
028.txt | WA | 282 ms | 4224 KB |
029.txt | WA | 231 ms | 4224 KB |
030.txt | WA | 225 ms | 4224 KB |
031.txt | WA | 220 ms | 4224 KB |
032.txt | WA | 279 ms | 4224 KB |
033.txt | WA | 239 ms | 4224 KB |
034.txt | WA | 253 ms | 4224 KB |
035.txt | WA | 233 ms | 4232 KB |
036.txt | WA | 263 ms | 4232 KB |
example0.txt | AC | 17 ms | 3188 KB |
example1.txt | AC | 17 ms | 3188 KB |