我的差分彻底歇*咯~~~~~(

蒙自市凤凰小学又阝十尃亻二 · 发布于 2023-05-08 · 浏览 668 回复 0

include

using namespace std; const long long N = 100010; long long n, m, x; long long a[N], b[N];

void insert(int l, int r, int c) {

b[l] += c;
b[r + 1] -= c;

}

int main() {

long long maxx = -11, mina = 100000007, x, y;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
	x = 0;
	insert(i, i, x);
}
while (m--) {
	int l, r, c;
	scanf("%d%d%d", &l, &r, &c);
	insert(l, r, c);
}
for (int i = 1; i <= n; i++) {
	a[i] = b[i] + a[i - 1];
	if (maxx < a[i]) {
		maxx = a[i];
		x = i;
	}
	if (mina > a[i]) {
		mina = a[i];
		y = i;
	}
}
cout << y << " " << x;
return 0;

}

全部回复 共 0 条

还没有人回复。往下写第一条。

发表回复