Submission #981926

#TimeUsernameProblemLanguageResultExecution timeMemory
981926vjudge1Sequence (APIO23_sequence)C++17
7 / 100
78 ms13396 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector <ll>; using vi = vector <int>; using ii = pair <ll, ll>; using vii = vector <ii>; int sequence (int n, vi ve) { for (int &i : ve) i--; vi v2 = ve; sort(v2.begin(), v2.end()); ll med = v2[(n-1)/2]; ll ans = 0; vll freq(n, 0); for (int i : ve) freq[i]++; for (ll i = med; i < n; i++) { ans = max(ans, freq[i]); } freq.assign(n, 0); ll i = 0; for (; i < n; i++) { if (!i || ve[i-1] <= ve[i]) { ans = max(ans, ++freq[ve[i]]); } else break; } freq.assign(n, 0); for (; i < n; i++) { if (!i || ve[i-1] >= ve[i]) { ans = max(ans, ++freq[ve[i]]); } else break; } return int(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...