QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#644060#4629. Longest Increasing SubsequenceMine_KingWA 0ms3928kbC++14948b2024-10-16 10:33:202024-10-16 10:33:20

Judging History

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

  • [2024-10-16 10:33:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3928kb
  • [2024-10-16 10:33:20]
  • 提交

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'