| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1334179 | SulA | 서열 (APIO23_sequence) | C++20 | 0 ms | 0 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;
template<typename T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
int sequence(int n, vector<int> a) {
auto b = a;
ranges::sort(b);
int med = b[(n-1)/2];
map<int,int> frq;
int ans = 1;
for (int x : a) {
if (x >= med) {
ans = max(ans, ++frq[x]);
}
}
// cout<<med<<'\n';
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << sequence(9, {1, 1, 2, 3, 4, 3, 2, 1, 1});
}