QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#50949 | #4629. Longest Increasing Subsequence | namelessgugugu | WA | 1ms | 1764kb | C++14 | 993b | 2022-09-29 20:20:26 | 2022-09-29 20:20:28 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
#define FILEIO(filename) (freopen(filename ".in", "r", stdin), freopen(filename ".out", "w", stdout))
typedef long long ll;
typedef unsigned long long ull;
const int N = 100005;
int n;
ll a[N], f[62];
int main(void)
{
scanf("%d", &n);
for (int i = 1;i <= n;++i)
scanf("%lld", a + i);
for (int i = 0; i < 62;++i)
f[i] = 1;
for (int i = 1; i < n; ++i)
{
++f[0];
ll len = a[i + 1] - a[i];
for (int k = 61; k >= 1; --k)
if(len >= (1ll << k) - 1)
{
f[k] += 1 << (k - 1);
}
else if(len >= (1ll << (k - 1)))
{
ll val = len - (1 << (k - 1)) + 1;
f[k] = std::max(f[i] + val, f[k - 1] + val + 1);
}
for (int k = 1; k < 62;++k)
f[k] = std::max(f[k], f[k - 1]);
}
printf("%lld\n", f[61]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 1764kb
input:
7 7 41 53 58 75 78 81
output:
19
result:
wrong answer 1st lines differ - expected: '22', found: '19'