제출 #959205

#제출 시각아이디문제언어결과실행 시간메모리
959205kilkuwu서열 (APIO23_sequence)C++17
28 / 100
2083 ms54476 KiB
#include "sequence.h" #include <bits/stdc++.h> int sequence(int N, std::vector<int> A) { int ans = 1; for (int i = 0; i < N; i++) { std::map<int, int> mp; std::multiset<int> s; mp[A[i]]++; s.insert(A[i]); auto it = s.begin(); int idx = 0; for (int j = i + 1; j < N; j++) { s.insert(A[j]); mp[A[j]]++; if (A[j] < *it) { idx++; } int med_idx = s.size() / 2; if (idx < med_idx) { it++; idx++; } if (idx > med_idx) { it--; idx--; } ans = std::max(ans, mp[*it]); if (s.size() % 2 == 0) { ans = std::max(ans, mp[*std::prev(it)]); } } } return ans; } #ifdef LOCAL #include <cassert> #include <cstdio> #include <vector> int main() { int N; assert(1 == scanf("%d", &N)); std::vector<int> A(N); for (int i = 0; i < N; ++i) { assert(1 == scanf("%d", &A[i])); } int result = sequence(N, A); printf("%d\n", result); return 0; } #endif
#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...