Submission #1061276

#TimeUsernameProblemLanguageResultExecution timeMemory
1061276Halym2007Sequence (APIO23_sequence)C++17
0 / 100
70 ms13392 KiB
#include <bits/stdc++.h> //#include "sequence.h" using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <int, int> const int N = 5e5 + 5; int a[N], st[N], n, val[N], sana[N]; int sequence(int N, vector<int> A) { n = N; for (int i = 0; i < n; ++i) { a[i] = A[i]; val[i] = -1; sana[i + 1] = 0; } int jogap = 1; for (int i = 0; i < n; ++i) { sana[a[i]]++; if (val[a[i]] == -1) { val[a[i]] = i; continue; } else { int san = i - val[a[i]] + 1; pii x = {(san - 1) / 2 + 1, san / 2 + 1}; int san1 = sana[a[i]]; if (san1 >= x.ff) { jogap = max (jogap, sana[a[i]]); } // if (jogap == 3) { // cout << i << " " << a[i] << " " << val[a[i]] << " " << sana[a[i]]; // exit(0); // } } } reverse (a,a + n); for (int i = 0; i < n; ++i) { val[i] = -1; sana[i + 1] = 0; // cout << a[i] << " "; } // cout << "\n"; for (int i = 0; i < n; ++i) { sana[a[i]]++; if (val[a[i]] == -1) { val[a[i]] = i; continue; } else { int san = i - val[a[i]] + 1; pii x = {(san - 1) / 2 + 1, san / 2 + 1}; int san1 = sana[a[i]]; if (san1 >= x.ff) { jogap = max (jogap, sana[a[i]]); } // if (jogap == 3) { // cout << i << " " << a[i] << " " << val[a[i]] << " " << sana[a[i]]; // exit(0); // } } } return jogap; } //int main() { // freopen ("input.txt", "r", stdin); // 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; //}
#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...