Submission #752208

#TimeUsernameProblemLanguageResultExecution timeMemory
752208aryan12Sequence (APIO23_sequence)C++17
7 / 100
468 ms53248 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int sequence(int n, vector<int> a) { int pos = 0; vector<int> b = a; sort(b.begin(), b.end()); int min_median = b[n / 2]; for(int i = 0; i < n - 1; i++) { if(a[i] <= a[i + 1]) { continue; } else { pos = i; break; } } for(int i = n - 1; i > 1; i--) { if(a[i] <= a[i - 1]) { continue; } else { pos = i; break; } } map<int, int> freq1, freq2; for(int i = 0; i <= pos; i++) { freq1[a[i]]++; } for(int i = n - 1; i > pos; i--) { freq2[a[i]]++; } int ans = 0; for(int i = 1; i <= n; i++) { if(i < min_median) { ans = max(ans, max(freq1[i], freq2[i])); } else { ans = max(ans, freq1[i] + freq2[i]); } } 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...