Submission #3007328
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]+f[0]) for i in range(3,m-1): f.append(x[i] + max(f[i-2][0],f[i-3][0])) f.append(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(res,count)
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | Indeedtest0791 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1192 Byte |
Status | RE |
Exec Time | 282 ms |
Memory | 6932 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 | WA | 135 ms | 3704 KB |
001.txt | RE | 82 ms | 3444 KB |
002.txt | RE | 134 ms | 4108 KB |
003.txt | RE | 79 ms | 3820 KB |
004.txt | RE | 115 ms | 4248 KB |
005.txt | RE | 129 ms | 4768 KB |
006.txt | RE | 42 ms | 3316 KB |
007.txt | RE | 76 ms | 3572 KB |
008.txt | RE | 22 ms | 3188 KB |
009.txt | RE | 186 ms | 3960 KB |
010.txt | WA | 235 ms | 4224 KB |
011.txt | RE | 249 ms | 4232 KB |
012.txt | RE | 243 ms | 4756 KB |
013.txt | RE | 253 ms | 5780 KB |
014.txt | RE | 270 ms | 6684 KB |
015.txt | RE | 245 ms | 6932 KB |
016.txt | RE | 261 ms | 6676 KB |
017.txt | RE | 254 ms | 6036 KB |
018.txt | RE | 252 ms | 5140 KB |
019.txt | RE | 237 ms | 4232 KB |
020.txt | WA | 230 ms | 4232 KB |
021.txt | WA | 249 ms | 4224 KB |
022.txt | WA | 279 ms | 4232 KB |
023.txt | RE | 280 ms | 4232 KB |
024.txt | RE | 268 ms | 4224 KB |
025.txt | RE | 252 ms | 4224 KB |
026.txt | RE | 257 ms | 4224 KB |
027.txt | RE | 230 ms | 4224 KB |
028.txt | RE | 282 ms | 4224 KB |
029.txt | RE | 239 ms | 4224 KB |
030.txt | RE | 248 ms | 4232 KB |
031.txt | RE | 265 ms | 4232 KB |
032.txt | RE | 218 ms | 4232 KB |
033.txt | RE | 213 ms | 4232 KB |
034.txt | RE | 258 ms | 4224 KB |
035.txt | RE | 271 ms | 4224 KB |
036.txt | RE | 259 ms | 4224 KB |
example0.txt | WA | 18 ms | 3188 KB |
example1.txt | WA | 18 ms | 3188 KB |