求大佬点进来看一看
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/7/20 19:48
  • 上次更新2024/7/20 21:01:42
查看原帖
求大佬点进来看一看
1001535
封禁用户楼主2024/7/20 19:48
int fu() {
	int ans  = 0;
	for (int i = 1; i <= n; i++) {
		int t = s[n] - s[i] - c[i];
		ans =  max(t, ans);
	}
	return ans;
}

int zheng() {
	int ans  = 0;
	for (int i = 2; i <= n ; i++) {
		int t = -s[i - 1]  + s[n - i] + c[i];
		ans =  max(t, ans);
	}
	return ans;
}
int zero() {
	int ans = 0;
	int t = 0;
	int xx = 0, yy = 0;
	for (int i = 1; i <= n; i++)
		if (c[i] < 0) {
			xx = i;
			break;
		}
	xx--;
	for (int i = n; i >= 1; i--)if (c[i] > 0) {
			yy = i;
			break;
		}
	yy++;
	t = 0;
	if (xx > 0)
		for (int i = 1; i <= xx; i++) {
			t = max(t, s[xx] - s[i] - c[i]);
		}

	ans += t;
// 	t = 0;
	if (xx + 1 <= yy - 1)
		for (int i = xx + 1; i <= yy - 1; i ++) {
			ans += abs(c[i]);
		}
//
	t = 0;
	if (yy <= n)
		for (int i = yy + 1; i <= n; i ++) {
			t = max(t, s[yy - 1] - s[i - 1] + c[i]);
		}

	ans += t;

	return ans;
}

时间复杂度是多少?(估计大概的就行),谢谢!

2024/7/20 19:48
加载中...