Submission #981944

#TimeUsernameProblemLanguageResultExecution timeMemory
981944MaaxleSequence (APIO23_sequence)C++17
0 / 100
2059 ms6300 KiB
#include "sequence.h" #include <bits/stdc++.h> #define range(it, a, b) for (ll it = a; it < b; it++) #define all(x) begin(x), end(x) #define ll long long #define ull unsigned long long #define INF64 ((ll) 1 << 62) #define INF32 (1 << 30) #define mset multiset #define uset unordered_set #define umap unordered_map #define pqueue priority_queue #define ptr(A) shared_ptr<A> using namespace std; struct BIT { vector<int> bit; BIT (int sz) { bit.resize(sz, 0); } void update(int i, int d) { for ( ; i < bit.size(); i |= i + 1) bit[i] += d; } int sum(int i) { int ans = 0; for ( ; i >= 0; i = (i & (i + 1)) - 1) ans += bit[i]; return ans; } int sum (int l, int r) { return sum(r) - (l ? sum(l - 1) : 0); } }; int query(int i, BIT& ft, int& N) { int l = 1, r = N, m; while (l < r) { m = (l+r)/2; if (ft.sum(m) >= i) r = m; else l = m+1; } return ft.sum(l, l); } int sequence(int N, vector<int> A) { int maxi = 0; for (int l = 0; l < N; l++) { BIT ft (N+1); for (int r = l; r < N; r++) { ft.update(A[r], 1); int sz = r-l+1; int a = sz/2; maxi = max(maxi, query(a+1, ft, N)); if ((sz & 1) && sz > 1) maxi = max(maxi, query(a+2, ft, N)); } } return maxi; }

Compilation message (stderr)

sequence.cpp: In member function 'void BIT::update(int, int)':
sequence.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for ( ; i < bit.size(); i |= i + 1)
      |             ~~^~~~~~~~~~~~
#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...