QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#644081 | #4629. Longest Increasing Subsequence | Mine_King | WA | 1ms | 6036kb | C++14 | 1.0kb | 2024-10-16 10:46:45 | 2024-10-16 10:46:46 |
Judging History
answer
// 長い夜の終わりを信じながら
// Think twice, code once.
#include <map>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define eputchar(c) putc(c, stderr)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define eputs(str) fputs(str, stderr), putc('\n', stderr)
using namespace std;
int n;
long long a[100005], dp[100005][65], num[65];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
fill(dp[1], dp[1] + 60, 1);
for (int i = 2; i <= n; i++) {
dp[i][0] = dp[i - 1][0] + 1;
long long tot = a[i] - a[i - 1] - 1;
for (int j = 1; j <= 60; j++) {
num[j] = min(tot, 1ll << (j - 1));
tot -= num[j];
}
for (int j = 1; j <= 60; j++) {
long long val =
j == 1 ? 0 : (num[j - 1] * 2 == num[j] ? num[j] : max(num[j] + 1, num[j - 1] + 1));
dp[i][j] = max(dp[i - 1][j] + num[j], dp[i - 1][j - 1] + val);
dp[i][j] = max(dp[i][j], dp[i][j - 1]);
}
}
printf("%lld\n", dp[n][60]);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3956kb
input:
7 7 41 53 58 75 78 81
output:
22
result:
ok single line: '22'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
8 174 223 259 368 618 738 893 1810
output:
671
result:
ok single line: '671'
Test #3:
score: 0
Accepted
time: 1ms
memory: 6036kb
input:
62 145 189 225 631 638 643 880 1349 1399 1574 1655 1713 1714 2383 2496 2706 2787 2904 2985 3030 3050 3318 3461 3466 3500 3908 3945 4287 4379 4412 4579 4612 4630 4722 4781 4811 4858 4998 5098 5276 6181 6185 6412 6427 6464 6498 6548 6887 6917 7344 7532 7776 8347 8711 8928 8983 9269 9486 9517 9833 9855...
output:
2506
result:
ok single line: '2506'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3896kb
input:
88 682 1542 2371 3402 5534 5587 7551 7837 8115 8420 8454 10265 12203 13354 14558 16443 16736 17324 17392 18981 22237 23902 24464 25309 26212 26253 27476 30809 32134 32566 32849 34823 35328 35390 35854 35927 35990 38817 38994 39401 39538 40551 41828 42329 42797 44736 49297 52129 52636 53241 53982 586...
output:
26800
result:
wrong answer 1st lines differ - expected: '26799', found: '26800'