# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
901552 | OAleksa | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 3 ms | 2648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int N = 1e5 + 69;
int n, a[N], b[N], dp[N], par[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++)
cin >> a[i];
for (int i = 1;i <= n;i++)
cin >> b[i];
dp[1] = 1;
for (int i = 2;i <= n;i++) {
for (int j = i - 1;j >= 1;j--) {
int x = __builtin_popcount((a[i] & a[j]));
if (x == b[i]) {
if (dp[j] + 1 > dp[i]) {
par[i] = j;
dp[i] = dp[j] + 1;
}
}
}
}
int mx = 1;
for (int i = 2;i <= n;i++) {
if (dp[i] > dp[mx])
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |