QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#50951 | #4629. Longest Increasing Subsequence | namelessgugugu | WA | 1ms | 1788kb | C++14 | 969b | 2022-09-29 20:30:40 | 2022-09-29 20:30:42 |
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] - 1;
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 - (1ll << (k - 1)) + 2;
f[k] = std::max(f[k] + 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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 1788kb
input:
7 7 41 53 58 75 78 81
output:
22
result:
ok single line: '22'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 1776kb
input:
8 174 223 259 368 618 738 893 1810
output:
672
result:
wrong answer 1st lines differ - expected: '671', found: '672'