Submission #1847416
Source Code Expand
#include<bits/stdc++.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) for(int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; //const int INF = 1e8; using namespace std; int oddVector(vector<int> v){ int res = 0; auto it = min_element(all(v)); for (auto i = v.begin(); i != it; i+=2) { res += max(*i, *next(i,1)); } for (auto i = next(it,1); i != v.end(); i+=2) { res += max(*i, *next(i,1)); } return res; } int countOp(vector<int> v){ if(v.size() % 2){ return oddVector(v); }else{ } } int main(){ int n; string s; cin >> n >> s; s+="0"; vector<int> v; int cnt = 0, ans = 0; rep(i,s.size()){ if(s[i] == '1'){ cnt++; }else if(s[i] == '0'){ v.emplace_back(cnt); cnt = 0; } } //for(auto j : v){ cout << j << ' '; } cout << endl; vector<int> dp(v.size(), 0); dp[1] = max(v[0], v[1]); range(i,1,v.size() - 1){ dp[i + 1] = max(dp[i + 1], dp[i]); if(v[i] == 0 || v[i + 1] == 0) continue; //for(auto j : dp){ cout << j << ' '; } cout << endl; dp[i + 1] = max(dp[i + 1], dp[i - 1] + max(v[i], v[i + 1])); } //for(auto j : dp){ cout << j << ' '; } cout << endl; cout << dp[v.size() - 1] << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - 101 to 010 |
User | noy72 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1295 Byte |
Status | WA |
Exec Time | 23 ms |
Memory | 4856 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 | 12 ms | 2424 KB |
001.txt | WA | 7 ms | 1404 KB |
002.txt | WA | 11 ms | 2040 KB |
003.txt | WA | 7 ms | 1148 KB |
004.txt | WA | 9 ms | 1276 KB |
005.txt | WA | 11 ms | 1404 KB |
006.txt | WA | 3 ms | 512 KB |
007.txt | WA | 6 ms | 640 KB |
008.txt | WA | 2 ms | 256 KB |
009.txt | WA | 14 ms | 900 KB |
010.txt | AC | 22 ms | 4856 KB |
011.txt | WA | 22 ms | 4472 KB |
012.txt | WA | 22 ms | 4088 KB |
013.txt | WA | 23 ms | 3704 KB |
014.txt | WA | 23 ms | 3320 KB |
015.txt | WA | 22 ms | 2940 KB |
016.txt | WA | 22 ms | 2556 KB |
017.txt | WA | 21 ms | 2172 KB |
018.txt | WA | 20 ms | 1792 KB |
019.txt | WA | 18 ms | 1156 KB |
020.txt | AC | 18 ms | 900 KB |
021.txt | AC | 18 ms | 900 KB |
022.txt | WA | 18 ms | 900 KB |
023.txt | WA | 18 ms | 900 KB |
024.txt | WA | 18 ms | 900 KB |
025.txt | WA | 18 ms | 900 KB |
026.txt | WA | 18 ms | 900 KB |
027.txt | WA | 18 ms | 900 KB |
028.txt | WA | 18 ms | 900 KB |
029.txt | WA | 18 ms | 900 KB |
030.txt | WA | 18 ms | 900 KB |
031.txt | WA | 18 ms | 900 KB |
032.txt | WA | 18 ms | 900 KB |
033.txt | WA | 18 ms | 900 KB |
034.txt | WA | 18 ms | 900 KB |
035.txt | WA | 18 ms | 900 KB |
036.txt | WA | 18 ms | 1156 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |