QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#388272 | #4629. Longest Increasing Subsequence | james1BadCreeper | WA | 1ms | 5724kb | C++14 | 968b | 2024-04-13 14:22:33 | 2024-04-13 14:22:33 |
Judging History
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;
}
詳細信息
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'