제출 #1061147

#제출 시각아이디문제언어결과실행 시간메모리
1061147Halym2007서열 (APIO23_sequence)C++17
28 / 100
2063 ms10076 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]; void gosh (int x) { for (int i = x; i <= n; i += i&(-i)) { st[i]++; } } int answer (int x) { int ret = 0; for (int i = x; i > 0; i -= i&(-i)) { ret += st[i]; } return ret; } int cykar (int x, int den) { int l = 1, r = n; while (l <= r) { int md = (l + r) / 2; 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) { for (int j = i; j < n; ++j) { gosh(a[j]); val[a[j]]++; pii x; int san = j - i + 1; x.ff = cykar ((san - 1) / 2 + 1, san); x.ss = cykar (san / 2 + 1, san); int ans1 = val[x.ff], ans2 = val[x.ss]; jogap = max ({ans1, ans2, jogap}); } for (int j = 0; j <= n; ++j) { st[j] = 0; val[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; //} //

컴파일 시 표준 에러 (stderr) 메시지

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