80pts求调
查看原帖
80pts求调
1559398
WA_csp_noip楼主2024/11/19 22:41

球球各位大佬帮我看一下感觉写的没有什么问题

orz orz orz

代码:

#include <stdio.h>
#include <algorithm>
#define int long long
#define line __int128
using namespace std;

int a[1000001], b[1000001], dp[1000001], c[1000001];
int n, p;

signed main() {
	scanf("%lld%lld", &n, &p);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	b[1] = dp[1] = a[1];
	for (int i = 2; i <= n; i++) {
		dp[i] = max(dp[i - 1] + a[i], a[i]);
		b[i] = max(b[i - 1], dp[i]);
	}
	c[1] = b[1], c[2] = b[1] + a[1];
	for (int i = 3; i <= n; i++)
		c[i] = max(c[i - 1], c[i - 1] + b[i - 1]);
	line ans = c[1];
	for (int i = 2; i <= n; i++)
		ans = max(ans, (line)(c[i]));
	printf("%d", (signed)(ans % p));
}

md这哪里错了呀

2024/11/19 22:41
加载中...