Submission #3415390
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int MXN = 500010; int n, f[MXN]; char str[MXN]; void solve() { cin >> n; cin >> str + 1; for (int i = 2; i <= n; ++i) { f[i] = max(f[i], f[i - 1]); if (str[i] == '0' && str[i - 1] == '1' && str[i + 1] == '1') { for (int k = i - 1; str[k] == '1'; --k) f[i + 1] = max(f[i + 1], f[k - 1] + i - k); for (int k = i + 1; str[k] == '1'; ++k) f[k] = max(f[k], f[i - 2] + k - i); } } cout << f[n] << endl; } int main() { solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | Laurant |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 539 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 2688 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 10 ms | 1408 KB |
001.txt | AC | 6 ms | 896 KB |
002.txt | AC | 9 ms | 1408 KB |
003.txt | AC | 6 ms | 896 KB |
004.txt | AC | 8 ms | 1152 KB |
005.txt | AC | 10 ms | 1408 KB |
006.txt | AC | 3 ms | 512 KB |
007.txt | AC | 6 ms | 768 KB |
008.txt | AC | 1 ms | 256 KB |
009.txt | AC | 15 ms | 2048 KB |
010.txt | AC | 18 ms | 2688 KB |
011.txt | AC | 18 ms | 2688 KB |
012.txt | AC | 18 ms | 2688 KB |
013.txt | AC | 19 ms | 2688 KB |
014.txt | AC | 20 ms | 2688 KB |
015.txt | AC | 20 ms | 2688 KB |
016.txt | AC | 20 ms | 2688 KB |
017.txt | AC | 20 ms | 2688 KB |
018.txt | AC | 19 ms | 2688 KB |
019.txt | AC | 19 ms | 2688 KB |
020.txt | AC | 18 ms | 2688 KB |
021.txt | AC | 19 ms | 2688 KB |
022.txt | AC | 19 ms | 2688 KB |
023.txt | AC | 19 ms | 2688 KB |
024.txt | AC | 19 ms | 2688 KB |
025.txt | AC | 19 ms | 2688 KB |
026.txt | AC | 19 ms | 2688 KB |
027.txt | AC | 19 ms | 2688 KB |
028.txt | AC | 19 ms | 2688 KB |
029.txt | AC | 19 ms | 2688 KB |
030.txt | AC | 19 ms | 2688 KB |
031.txt | AC | 19 ms | 2688 KB |
032.txt | AC | 19 ms | 2688 KB |
033.txt | AC | 19 ms | 2688 KB |
034.txt | AC | 19 ms | 2688 KB |
035.txt | AC | 19 ms | 2688 KB |
036.txt | AC | 19 ms | 2688 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |