제출 #1061254

#제출 시각아이디문제언어결과실행 시간메모리
1061254Halym2007서열 (APIO23_sequence)C++17
0 / 100
51 ms12128 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 (i == 8 and a[i] == 3) { // cout << san << " " << san1 << " " << sana[a[i]] << " " << x.ff; // exit(0); // } // if (san1 >= x.ff) { jogap = max (jogap, sana[a[i]]); } } } reverse (a + 1,a + n + 1); for (int i = 0; i < n; ++i) { val[i] = -1; sana[i + 1] = 0; } 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 = san - val[a[i]]; if (san1 <= x.ff) { jogap = max (jogap, val[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...