#include<bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 5;
const long long inf = 1000000000;
#define ll long long
#define F first
#define S second
#define pb push_back
int n, m, a[N], k, l, r, ans[N];
ll b[N], x;
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= m; ++i){
cin >> a[i];
}
for(int i = 1; i <= n; ++i){
cin >> b[i];
}
cin >> k;
if(k > 1e4 || m > 1e4 || n > 1e4) {
cout << "GG WP";
return 0;
}
for(int i = 1; i <= k; ++i){
cin >> l >> r >> x;
if(l <= r){
for(int j = l; j <= r; ++j){
if(b[a[j]] <= 0) continue;
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) ans[a[j]] = i;
}
}
}
else{
for(int j = l; j <= m; ++j){
if(b[a[j]] <= 0) continue;
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) ans[a[j]] = i;
}
}
for(int j = 1; j <= r; ++j){
if(b[a[j]] <= 0) continue;
else{
b[a[j]] -= x;
if(b[a[j]] <= 0) ans[a[j]] = i;
}
}
}
// for(int i = 1; i <= n; ++i){
// cout << b[i] << ' ';
// }
// cout << '\n';
}
for(int i = 1; i <= n; ++i){
if(ans[i]) cout << ans[i] << '\n';
else cout << "NIE\n";
}
}
Compilation message
met.cpp:15:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
15 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
2204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
2116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |