蒙自市凤凰小学又阝十尃亻二 • 1年前
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;
}
评论:
请先登录,才能进行评论