QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#644060 | #4629. Longest Increasing Subsequence | Mine_King | WA | 0ms | 3928kb | C++14 | 948b | 2024-10-16 10:33:20 | 2024-10-16 10:33:20 |
Judging History
answer
// 長い夜の終わりを信じながら
// Think twice, code once.
#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++) {
dp[i][j] = max(dp[i - 1][j] + num[j], dp[i - 1][j - 1] + num[j - 1] - num[j] / 2 + num[j]);
dp[i][j] = max(dp[i][j], dp[i][j - 1]);
}
}
printf("%lld\n", dp[n][60]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
7 7 41 53 58 75 78 81
output:
22
result:
ok single line: '22'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3928kb
input:
8 174 223 259 368 618 738 893 1810
output:
747
result:
wrong answer 1st lines differ - expected: '671', found: '747'