Files
python/TangDou/Topic/PrefixAndSuffix/P1083_0.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

28 lines
696 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}