Submission #983919

#TimeUsernameProblemLanguageResultExecution timeMemory
983919VvnxSequence (APIO23_sequence)C++17
11 / 100
2059 ms4768 KiB
#include "sequence.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll,ll> #define pb push_back #define fi first #define se second const ll N = 5e5+3; vector<int> v,aa; ll m,tmp,ans,bb,tmp1; int sequence(int n, vector<int> a) { for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { v.clear(); for(int k=i; k<=j; k++) { v.pb(a[k]); } sort(v.begin(),v.end()); tmp = 0; if((j-i+1) % 2 == 1) { for(int k=i; k<=j; k++) { if(a[k] == v[v.size()/2]) { tmp++; } } } else { tmp1 = 0; for(int k=i; k<=j; k++) { if(a[k] == v[v.size()/2]) { tmp++; } else if(a[k] == v[v.size()/2-1]) { tmp1++; } } tmp = max(tmp,tmp1); } ans = max(ans,tmp); } } return ans; } //int main() { // cin >> m; // for(int i=1; i<=m; i++) { // cin >> bb; // aa.pb(bb); // } // cout << sequence(m,aa) << endl; //} /* 7 1 2 3 1 2 1 3 out : 3 9 1 1 2 3 4 3 2 1 1 out : 2 14 2 6 2 5 3 4 2 1 4 3 5 6 3 2 out : 3 */
#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...