Submission #1061136

#TimeUsernameProblemLanguageResultExecution timeMemory
1061136Halym2007Sequence (APIO23_sequence)C++17
11 / 100
2072 ms34892 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; void gosh (int x) { for (int i = x; i <= n; i += i&(-i)) { st[i]++; } } int answer (int x) { int ret = 0; // int kk = 0; for (int i = x; i > 0; i -= i&(-i)) { // cout << i << " --> " ; // kk++; // if (kk == 15) { // exit(0); // } ret += st[i]; } return ret; } int cykar (int x, int den) { // cout << x << "\n"; int l = 1, r = n; while (l <= r) { int md = (l + r) / 2; // cout << l << " " << r << "\n"; int jj = answer(md); if (jj < x) { l = md + 1; } else if (x <= jj and answer(md - 1) < x) { return md; } else { r = md - 1; } } } int sequence(int N, vector<int> A) { n = N; for (int i = 0; i < N; ++i) { a[i] = A[i]; } int jogap = 0; for (int i = 0; i < n; ++i) { multiset <int> s; for (int j = i; j < n; ++j) { gosh(a[j]); s.insert (a[j]); pii x; // cout << i << " " << j << "\n"; int san = j - i + 1; x.ff = cykar ((san - 1) / 2 + 1, san); x.ss = cykar (san / 2 + 1, san); // cout << x.ff << " " << x.ss << "<---"; // exit(0); int ans1 = s.count(x.ff), ans2 = s.count(x.ss); jogap = max ({ans1, ans2, jogap}); // if (jogap == 4) { // cout << i << " " << j << " " << x.ff << " " << x.ss; // exit(0); // } } for (int j = 0; j <= n; ++j) { st[j] = 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; //} //

Compilation message (stderr)

sequence.cpp: In function 'int cykar(int, int)':
sequence.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^
#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...