Submission #229226

# Submission time Handle Problem Language Result Execution time Memory
229226 2020-05-03T21:14:53 Z VEGAnn Preokret (COCI19_preokret) C++14
50 / 50
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
int a[N], kl = 0, ans =  1, n, sch[N][2];

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0);
    
//    freopen("in.txt","r",stdin);
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        kl += bool(a[i] == 1);
        
        sch[i][0] = kl;
        sch[i][1] = i + 1 - kl;
        
        if (kl == i + 1 - kl)
            ans++;
    }
    
    cout << kl << " " << n - kl << '\n';
    cout << ans << '\n';
    
    ans = 0;
    
    for (int tp = 0; tp < 2; tp++)
        for (int i = 0; i < n; i++){
            if (sch[i][tp] <= sch[i][tp ^ 1]) continue;
            
            int len = 1;
            
            for (int j = i + 1; j < n; j++){
                if (sch[j][tp] != sch[j - 1][tp]) break;
                
                len++;
            }
            
            if (sch[i + len - 1][tp ^ 1] > sch[i][tp])
                ans = max(ans, len - 1);
        }
    
    cout << ans << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct