80, 第五个wa了

P2367 语文成绩

koromu @ 2023-11-10 20:31:30

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;

const int N = 1000010;
int a[N], s[N];
int n, p;
int x, y, z;

int main()
{
    scanf("%d%d", &n, &p);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);

    for (int i = 1; i <= n; i++)
        s[i] = a[i] - a[i-1] ;
    while (p--)
    {
        scanf("%d%d%d", &x, &y, &z);
        s[x] += z, s[y+1] -= z;
    }
    for (int i = 1; i <= n; i++) a[i] = s[i] + a[i-1];
    sort(a+1, a + n + 1);
    cout << a[1];
    return 0;
}

想不明白求指点呀


by OcTar @ 2023-11-10 21:07:05

@koromu n 的范围是 5\times 10^6,数组小了


by koromu @ 2023-11-10 21:28:41

@OcTar 收到


|