QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50951#4629. Longest Increasing SubsequencenamelessguguguWA 1ms1788kbC++14969b2022-09-29 20:30:402022-09-29 20:30:42

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:30:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:1788kb
  • [2022-09-29 20:30:40]
  • 提交

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'