QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50949#4629. Longest Increasing SubsequencenamelessguguguWA 1ms1764kbC++14993b2022-09-29 20:20:262022-09-29 20:20:28

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-29 20:20:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:1764kb
  • [2022-09-29 20:20:26]
  • 提交

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;
}

詳細信息

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'