diff options
Diffstat (limited to '327A')
| -rwxr-xr-x | 327A/main | bin | 0 -> 19776 bytes | |||
| -rw-r--r-- | 327A/main.cpp | 36 |
2 files changed, 36 insertions, 0 deletions
diff --git a/327A/main b/327A/main Binary files differnew file mode 100755 index 0000000..4b4db6d --- /dev/null +++ b/327A/main diff --git a/327A/main.cpp b/327A/main.cpp new file mode 100644 index 0000000..640a378 --- /dev/null +++ b/327A/main.cpp @@ -0,0 +1,36 @@ +#include <iostream> +#include <vector> + +using namespace std; + +int main(void){ + int a,b; + cin>>a; + vector<int> v1; + for(int i = 0; i < a; i++){ + cin>>b; + v1.push_back(b); + } + + int zeroes = 0; + int max_zeroes = 0; + int ones = 0; + + for(int i = 0; i < v1.size(); i++){ + if(v1.at(i) == 0){ + zeroes++; + if(zeroes > max_zeroes){ + max_zeroes = zeroes; + } + } + if(v1.at(i) == 1){ + if(zeroes != 0) zeroes--; + if(v1.size() != 1) ones++; + } + } + if(max_zeroes == 0 && v1.size() != 1){ + ones -= 1; + } + cout<<ones + max_zeroes; + return 0; +} |
