Submission #1061281

#TimeUsernameProblemLanguageResultExecution timeMemory
1061281Halym2007Sequence (APIO23_sequence)C++17
0 / 100
74 ms15436 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; memset(sana, 0, sizeof(sana)); memset (val, -1, sizeof(val)); for (int i = 0; i < n; ++i) { a[i] = A[i]; val[i] = -1; } 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); memset(sana, 0, sizeof(sana)); memset (val, -1, sizeof(val)); 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]]); } } } 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...