QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282012#323. HillsA_programmer0 1ms3556kbC++14814b2023-12-11 10:05:342023-12-11 10:05:36

Judging History

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

  • [2023-12-11 10:05:36]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3556kb
  • [2023-12-11 10:05:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int dp[2505][3], dp_n[2505][3];
int a[5005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[0] = a[n + 1] = -1e9;
	
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		memset(dp_n, 0x3f, sizeof(dp_n));
		for (int k = 0; k <= (i + 1) / 2; k++)
		{
			dp_n[k][0] = min(dp_n[k][0], min(dp[k][0], dp[k][1]));
			dp_n[k][1] = min(dp_n[k][1], dp[k][2] + max(0, a[i] - a[i - 1] + 1));
			if (k) dp_n[k][2] = min(dp_n[k][2], min(dp[k - 1][0], dp[k - 1][1]) + max(0, a[i - 1] - a[i] + 1));
		}
		memcpy(dp, dp_n, sizeof(dp_n));
	}
	for (int k = 1; k <= (n + 1) / 2; k++) cout << min(dp[k][0], min(dp[k][1], dp[k][2])) << " ";
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 7
Accepted
time: 1ms
memory: 3556kb

input:

3
1 2 4

output:

0 2 

result:

ok 2 number(s): "0 2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

3
3 2 1

output:

0 2 

result:

ok 2 number(s): "0 2"

Test #3:

score: -7
Wrong Answer
time: 0ms
memory: 3452kb

input:

3
1 2 1

output:

0 4 

result:

wrong answer 2nd numbers differ - expected: '2', found: '4'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%