Submission #933566

#TimeUsernameProblemLanguageResultExecution timeMemory
933566JuanJLSequence (APIO23_sequence)C++17
28 / 100
2081 ms35520 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define fst first #define snd second #define pb push_back #define forn(i,a,b) for(int i = a; i < b; i++) #define ALL(x) x.begin(),x.end() #define SZ(x) (int)x.size() #define mset(a,v) memset((a),(v),sizeof(a)) #define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n'; #define pi pair<int,int> #define pll pair<ll,ll> typedef long long ll; using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset; ll n; vector<ll> a; int sequence(int N, std::vector<int> A) { n=N; a.clear(); a.resize(n); forn(i,0,n) a[i]=A[i]; ll res = 0; forn(i,0,n){ indexed_multiset im; ll ocurr[n+1]; mset(ocurr,0); forn(j,i,n){ im.insert(a[j]); ocurr[a[j]]++; res = max(res,ocurr[*im.find_by_order((SZ(im)-1)/2)]); if(SZ(im)%2==0) res = max(res,ocurr[*im.find_by_order((SZ(im)-1)/2+1)]); } } return res; }
#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...