Submission #1009473

#TimeUsernameProblemLanguageResultExecution timeMemory
1009473pccSequence (APIO23_sequence)C++17
28 / 100
365 ms10320 KiB
#include "sequence.h" #include <vector> #include <bits/stdc++.h> #include <bits/extc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") using namespace std; using namespace __gnu_pbds; #define pii pair<int,int> #define fs first #define sc second template<typename T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; const int mxn = 5e3+10; int cnt[mxn],arr[mxn]; int N,ans; ordered_set<pii> st; void check(int head){ st.clear(); memset(cnt,0,sizeof(cnt)); for(int i = head;i<N;i++){ cnt[arr[i]]++; st.insert(pii(arr[i],i)); int tl = (st.size()-1)>>1,tr = st.size()>>1; int val = st.find_by_order(tl)->fs; ans = max(ans,cnt[val]); val = st.find_by_order(tr)->fs; ans = max(ans,cnt[val]); } return; } int sequence(int NN, std::vector<int> AA) { N = NN; for(int i = 0;i<N;i++)arr[i] = AA[i]; ans = 0; for(int i = 0;i<N;i++)check(i); return ans; }
#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...