Submission #769958

#TimeUsernameProblemLanguageResultExecution timeMemory
769958raysh07JOI 문장 (JOI14_ho_t1)C++17
0 / 100
1 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...