Submission #3007376
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 | 328 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 | AC | 117 ms | 3704 KB |
001.txt | WA | 90 ms | 3444 KB |
002.txt | WA | 134 ms | 4128 KB |
003.txt | WA | 85 ms | 3812 KB |
004.txt | WA | 112 ms | 4252 KB |
005.txt | WA | 156 ms | 4764 KB |
006.txt | WA | 50 ms | 3316 KB |
007.txt | WA | 81 ms | 3572 KB |
008.txt | WA | 22 ms | 3188 KB |
009.txt | WA | 185 ms | 3968 KB |
010.txt | AC | 215 ms | 4224 KB |
011.txt | WA | 271 ms | 4224 KB |
012.txt | WA | 238 ms | 4892 KB |
013.txt | WA | 293 ms | 5780 KB |
014.txt | WA | 288 ms | 6676 KB |
015.txt | WA | 328 ms | 6932 KB |
016.txt | WA | 328 ms | 6676 KB |
017.txt | WA | 328 ms | 6036 KB |
018.txt | WA | 320 ms | 5140 KB |
019.txt | WA | 292 ms | 4224 KB |
020.txt | AC | 227 ms | 4224 KB |
021.txt | AC | 280 ms | 4232 KB |
022.txt | WA | 236 ms | 4224 KB |
023.txt | WA | 263 ms | 4224 KB |
024.txt | WA | 261 ms | 4224 KB |
025.txt | WA | 232 ms | 4232 KB |
026.txt | WA | 276 ms | 4224 KB |
027.txt | WA | 247 ms | 4224 KB |
028.txt | WA | 286 ms | 4232 KB |
029.txt | WA | 244 ms | 4236 KB |
030.txt | WA | 242 ms | 4224 KB |
031.txt | WA | 249 ms | 4224 KB |
032.txt | WA | 222 ms | 4224 KB |
033.txt | WA | 225 ms | 4224 KB |
034.txt | WA | 223 ms | 4224 KB |
035.txt | WA | 229 ms | 4232 KB |
036.txt | WA | 283 ms | 4224 KB |
example0.txt | AC | 17 ms | 3188 KB |
example1.txt | AC | 17 ms | 3188 KB |