This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 1000010;
int r[N];
int main() {
cin >> n >> m;
// 每一天可租借教室数
for (int i = 1; i <= n; i++) cin >> r[i];
// 从哪天到哪天,借多少个
for (int i = 1; i <= m; i++) {
int d, s, t;
cin >> d >> s >> t;
// 从开始天到结束天
for (int j = s; j <= t; j++) {
r[j] -= d; // 减去借走的教室数
if (r[j] < 0) { // 小于0了!
cout << -1 << endl
<< i << endl;
return 0;
}
cout << 0 << endl;