28 lines
696 B
C++
28 lines
696 B
C++
#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;
|
||
return 0;
|
||
} |