Submission #1124157

#TimeUsernameProblemLanguageResultExecution timeMemory
1124157VinhLuuSequence (APIO23_sequence)C++20
11 / 100
2094 ms5252 KiB
#include <bits/stdc++.h> #include "sequence.h" #define ll long long #define all(lpv) lpv.begin(), lpv.end() #define fi first #define se second #define pot(x, y) lower_bound(x.begin(), x.end(), y) - x.begin() using namespace std; const int N = 2e5 + 5; int n, a[N]; namespace sub1 { int solve() { int ans = 1; for(int i = 1; i <= n; i ++) { vector<int> vr; for(int j = i; j <= n; j ++) { vr.push_back(a[j]); sort(all(vr)); if((int)vr.size() % 2) { int med = vr[(int)vr.size() / 2]; int cnt = 0; for(auto j : vr) cnt += (j == med); ans = max(ans, cnt); } else { int m1 = vr[(int)vr.size() / 2 - 1]; int m2 = vr[(int)vr.size() / 2]; int c1 = 0, c2 = 0; for(auto j : vr) { c1 += (j == m1); c2 += (j == m2); } ans = max(ans, max(c1, c2)); } } } return ans; } } int sequence(int _n, vector<int> A) { n = _n; for(int i = 1; i <= n; i ++) { a[i] = A[i - 1]; } return sub1 :: solve(); return 0; } //#define lpv #ifdef lpv signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")) { freopen(task ".inp","r",stdin); freopen(task ".ans","w",stdout); } int _n; cin >> _n; vector<int> A; for(int i = 1; i <= _n; i ++) { int x; cin >> x; A.push_back(x); } int result = sequence(_n, A); cout << result; } #endif // lpv
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...