Submission #981991

#TimeUsernameProblemLanguageResultExecution timeMemory
981991vjudge1Sequence (APIO23_sequence)C++17
0 / 100
959 ms2097152 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int sequence(int n, vector <int> a){ vector <vector <int>> repe(n+1, vector<int>(n+1)); for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ repe[i][j] = repe[i][j-1] + (a[j-1] == i); } } int ans = 0; for(int i=0; i<n; i++){ ordered_set st; for(int j=i; j<n; j++){ st.insert(a[j]); int x = st.order_of_key((j-i)/2); int y = st.order_of_key((j-i+1)/2); ans = max(ans, repe[x][j+1]-repe[x][i]); ans = max(ans, repe[y][j+1]-repe[y][i]); } st.clear(); } 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...