QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#388272#4629. Longest Increasing Subsequencejames1BadCreeperWA 1ms5724kbC++14968b2024-04-13 14:22:332024-04-13 14:22:33

Judging History

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

  • [2024-04-13 14:22:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5724kb
  • [2024-04-13 14:22:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 1e5 + 5, K = 61; 

int n, c[N];
i64 a[N], f[N][K]; // 前 i 个数,前 j 个

inline void chmax(i64 &x, i64 t) { if (x < t) x = t; }

int main(void) {
    ios::sync_with_stdio(0);
    cin >> n; --n; 
    for (int i = 0; i <= n; ++i) cin >> a[i]; 
    for (int i = n; i >= 1; --i) c[i] = __lg(a[i] -= a[i - 1]); 
    for (int i = 0; i < K; ++i) f[0][i] = 1; 
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < c[i]; ++j) f[i][j] = f[i - 1][j] + (1ll << j); 
        f[i][c[i]] = f[i - 1][c[i]] + a[i] - (1ll << c[i]); 
        
        if (c[i] && a[i] > 1ll << c[i])
            chmax(f[i][c[i]], f[i - 1][c[i] - 1] + max(0ll, a[i] - (1ll << c[i])) + 1); 
        for (int j = 0; j < K; ++j) chmax(f[i][j], f[i - 1][j]); 
        for (int j = 1; j < K; ++j) chmax(f[i][j], f[i][j - 1]); 
    }
    cout << f[n][K - 1] << '\n'; 
    return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5724kb

input:

7
7 41 53 58 75 78 81

output:

21

result:

wrong answer 1st lines differ - expected: '22', found: '21'