Submission #1085232

#TimeUsernameProblemLanguageResultExecution timeMemory
1085232TimoshSequence (APIO23_sequence)C++17
7 / 100
71 ms9556 KiB
#include <bits/stdc++.h> #include "sequence.h" using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key int sequence(int n, vector<int> A) { int ans = 1; int last = 0; vector<int> cnt(n + 1); for (int i = 0; i < n; i++) { if (last > A[i]) break; cnt[A[i]]++; ans = max(ans, cnt[A[i]]); last = A[i]; } last = 0; for (int i = 1; i <= n; i++) cnt[i] = 0; for (int i = n - 1; i >= 0; i--) { if (last > A[i]) break; last = A[i]; cnt[A[i]]++; ans = max(ans, cnt[A[i]]); } for (int i = 1; i <= n; i++) cnt[i] = 0; sort(A.begin(), A.end()); for (int i = 0; i < n; i++) cnt[A[i]]++; for (int i = n / 2; i < n; i++) ans = max(ans, cnt[A[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...