Submission #3007330
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(count)
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | Indeedtest0791 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1186 Byte |
Status | RE |
Exec Time | 305 ms |
Memory | 6804 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 | 117 ms | 3704 KB |
001.txt | RE | 75 ms | 3568 KB |
002.txt | RE | 128 ms | 4128 KB |
003.txt | RE | 85 ms | 3820 KB |
004.txt | RE | 105 ms | 4248 KB |
005.txt | RE | 135 ms | 4768 KB |
006.txt | RE | 41 ms | 3316 KB |
007.txt | RE | 76 ms | 3572 KB |
008.txt | RE | 22 ms | 3188 KB |
009.txt | RE | 170 ms | 3960 KB |
010.txt | AC | 219 ms | 4224 KB |
011.txt | RE | 236 ms | 4224 KB |
012.txt | RE | 249 ms | 4892 KB |
013.txt | RE | 256 ms | 5780 KB |
014.txt | RE | 249 ms | 6676 KB |
015.txt | RE | 247 ms | 6804 KB |
016.txt | RE | 241 ms | 6676 KB |
017.txt | RE | 267 ms | 6044 KB |
018.txt | RE | 268 ms | 5140 KB |
019.txt | RE | 223 ms | 4224 KB |
020.txt | AC | 296 ms | 4224 KB |
021.txt | AC | 227 ms | 4224 KB |
022.txt | WA | 264 ms | 4224 KB |
023.txt | RE | 250 ms | 4232 KB |
024.txt | RE | 224 ms | 4224 KB |
025.txt | RE | 257 ms | 4232 KB |
026.txt | RE | 305 ms | 4224 KB |
027.txt | RE | 240 ms | 4232 KB |
028.txt | RE | 265 ms | 4232 KB |
029.txt | RE | 287 ms | 4232 KB |
030.txt | RE | 263 ms | 4224 KB |
031.txt | RE | 222 ms | 4232 KB |
032.txt | RE | 257 ms | 4232 KB |
033.txt | RE | 300 ms | 4232 KB |
034.txt | RE | 260 ms | 4232 KB |
035.txt | RE | 216 ms | 4232 KB |
036.txt | RE | 257 ms | 4224 KB |
example0.txt | AC | 18 ms | 3188 KB |
example1.txt | AC | 17 ms | 3192 KB |