Submission #3007375
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(res,count)
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | Indeedtest0791 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1183 Byte |
Status | WA |
Exec Time | 354 ms |
Memory | 7828 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 | 120 ms | 3712 KB |
001.txt | WA | 95 ms | 3444 KB |
002.txt | WA | 137 ms | 4260 KB |
003.txt | WA | 87 ms | 4068 KB |
004.txt | WA | 124 ms | 4632 KB |
005.txt | WA | 187 ms | 5276 KB |
006.txt | WA | 47 ms | 3444 KB |
007.txt | WA | 91 ms | 3828 KB |
008.txt | WA | 23 ms | 3188 KB |
009.txt | WA | 225 ms | 3960 KB |
010.txt | WA | 244 ms | 4224 KB |
011.txt | WA | 257 ms | 4232 KB |
012.txt | WA | 266 ms | 5148 KB |
013.txt | WA | 290 ms | 6420 KB |
014.txt | WA | 283 ms | 7580 KB |
015.txt | WA | 312 ms | 7828 KB |
016.txt | WA | 354 ms | 7828 KB |
017.txt | WA | 329 ms | 7068 KB |
018.txt | WA | 333 ms | 5908 KB |
019.txt | WA | 263 ms | 4628 KB |
020.txt | WA | 239 ms | 4224 KB |
021.txt | WA | 288 ms | 4224 KB |
022.txt | WA | 274 ms | 4224 KB |
023.txt | WA | 254 ms | 4224 KB |
024.txt | WA | 230 ms | 4224 KB |
025.txt | WA | 232 ms | 4232 KB |
026.txt | WA | 225 ms | 4224 KB |
027.txt | WA | 226 ms | 4224 KB |
028.txt | WA | 224 ms | 4232 KB |
029.txt | WA | 223 ms | 4224 KB |
030.txt | WA | 225 ms | 4224 KB |
031.txt | WA | 272 ms | 4224 KB |
032.txt | WA | 219 ms | 4232 KB |
033.txt | WA | 251 ms | 4224 KB |
034.txt | WA | 277 ms | 4232 KB |
035.txt | WA | 245 ms | 4224 KB |
036.txt | WA | 269 ms | 4244 KB |
example0.txt | WA | 17 ms | 3188 KB |
example1.txt | WA | 17 ms | 3188 KB |