# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85823 | ToadDaveski | Longest beautiful sequence (IZhO17_subsequence) | C++11 | 4664 ms | 228108 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>
#define ll long long
using namespace std;
ll a[100001],k[100001],kolb[(1<<11)],dp[21][(1<<11)][(1<<11)],pr[100001],nom[21][(1<<11)][(1<<11)];
deque <ll> answer;
int main()
{
ll n,m,i,j,fin=-1,mdp=-1;
cin>>n;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
cin>>k[i];
for(i=1;i<=(1<<10);i++)
kolb[i]= __builtin_popcount(i);
for(i=1;i<=n;i++)
{
ll x=(a[i]>>10);
ll y=a[i]-(x<<10);
pr[i]=i;
ll ans=1;
for(j=0;j<=(1<<10);j++)
{
ll ob=kolb[y&j];
if (ob<=k[i] && k[i]-ob<=10 && dp[k[i]-ob][j][x]+1>ans)
{
//cout<<i<<"="<<j<<" "<<x<<" "<<nom[k[i]-ob][j][x]<<" "<<dp[k[i]-ob][j][x]<<" ";
ans=dp[k[i]-ob][j][x]+1;
pr[i]=nom[k[i]-ob][j][x];
}
Compilation message (stderr)
# | 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... |