Submission #769958

# Submission time Handle Problem Language Result Execution time Memory
769958 2023-06-30T15:09:16 Z raysh07 None (JOI14_ho_t1) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)1e18
#define f first
#define s second

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{
    int n; cin >> n;
    vector <int> a(n);
    for (auto &x : a) cin >> x;
    
    vector <int> b;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        cnt++;
        if (i == n - 1 || a[i] == a[i + 1]){
            b.push_back(cnt);
            cnt = 0;
        }
    }
    
    // cout << b.size() << "\n";
    
    int ans = b[0];
    for (int i = 0; i < (int)b.size() - 1; i++){
       // cout << i << " ";
        ans = max(ans, b[i] + b[i + 1]);
    }
  //  cout << "\n";
    for (int i = 0; i < (int)b.size() - 2; i++){
      ///  cout << i << " ";
        ans = max(ans, b[i] + b[i + 1] + b[i + 2]);
    }
  //  cout << "\n";
    
    cout << ans << "\n";
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
 //   cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        //cout << "Case #" << i << ": ";
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -