제출 #980492

#제출 시각아이디문제언어결과실행 시간메모리
980492thelegendary08서열 (APIO23_sequence)C++17
11 / 100
2091 ms7884 KiB
#include "sequence.h" #include<bits/stdc++.h> #define pb push_back #define ll long long int #define vi vector<int> #define vvi vector<vector<int>> #define vll vector<long long int> #define vvll vector<vector<long long int>> #define pii pair<int, int> #define vpii vector<pair<int, int>> #define vpll vector<pair<long long int, long long int>> #define pqpll priority_queue<pair<long long int, long long int>> #define vc vector<char> #define vvc vector<vector<char>> #define vb vector<bool> #define mii map<int,int> #define mll map<long long int, long long int> #define mivi map<int,vector<int>> #define f0r(i,n) for(int i=0;i<n;i++) #define FOR(i,k,n) for(int i=k;i<n;i++) using namespace std; vi med(vi v){ sort(v.begin(), v.end()); if(v.size()%2 == 1)return {v[v.size()/2]}; else return {v[v.size()/2 - 1], v[v.size()/2]}; } int sequence(int n, std::vector<int> v) { int ans = 0; f0r(i,n){ FOR(j, i, n){ vi tmp; FOR(k, i, j+1){ tmp.pb(v[k]); } vi md = med(tmp); //for(auto u : md)cout<<u<<' '; //cout<<'\n'; if(md.size() == 1) ans = max(ans,(int)count(tmp.begin(), tmp.end(), md[0])); else ans = max(ans, max((int)count(tmp.begin(), tmp.end(), md[0]), (int)count(tmp.begin(), tmp.end(), md[1]))); } } 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...