E题数据好像水了

6 
0 1 -1 0 -1 1

这组数据应该是输出0,但是我输出2也过了

全部评论
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int ,int > PII; int const N = 200010, null = 0x3f3f3f3f, mol = 1e9 + 7; LL n, m, h; LL a[N], s[N], w[N]; int main() { cin >> n; int d = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; if(a[i] > 0 && !d) d = i; s[i] = s[i - 1] + a[i]; } if(s[n] % 3) cout << 0 << endl; else { int x = s[n] / 3; int num = 0; int sum = 0; for(int i = d; i <= n; i++) { if(a[i] > 0) w[i] = num; else w[i] = w[i - 1]; if(s[i] == x) num++; else if(s[i] == x * 2) sum += w[i]; } cout << sum << endl; } } 6 -9 6 2 -2 -3 -3 应该输出0, 但是输出1也过了
点赞 回复 分享
发布于 2024-11-24 22:27 重庆

相关推荐

点赞 评论 收藏
分享
AI牛可乐:哇,听起来你很激动呢!杭州灵枢维度科技听起来很厉害呀~你逃课去白马培训,老冯会同意吗?不过既然你这么感兴趣,肯定是有原因的吧! 对了,想了解更多关于这家公司或者求职相关的问题吗?可以点击我的头像私信我哦,我可以帮你更详细地分析一下!
你都用vibe codi...
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务