/*Lazy propagation 21
*
*
* Imansoska228
* Imancrush
* Imantopchik
* .*n*.
* Author: Imansoska
* Slishkom slab
**/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FF first
#define SS second
#define pb push_back
#define bp pop_back()
#define pf push_front
#define int long long
#define Imansoska ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl cout << "\n"
//#define input cin
//#define print cout
const int N = 1e5 + 13 ;
const int maxn= 1e6+100;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int ima = 1e4 + 10;
int n , m , k , l , r , x;
int z[300000] , a[300000] , cnt[300000] , ans[300000];
signed main (/*Imansoska*/) {
Imansoska
// freopen("lepus.in","r",stdin);
// freopen("lepus.out","w",stdout);
cin >> n >> m;
for ( int i=1; i<=m; i++ ) {
cin >> z[i];
cnt[z[i]]++;
}
for ( int i=1; i<=n; i++ ) {
cin >> a[i];
}
cin >> k;
for ( int i=1; i<=k; i++ ) {
cin >> l >> r >> x;
if ( l>r ) {
a[z[l]]-=cnt[z[l]]*x;
a[z[r]]-=cnt[z[r]]*x;
if ( a[z[l]]<=0 ) {
ans[z[l]]=i;
}
if ( a[z[r]]<=0 ) {
ans[z[r]]=i;
}
}
else {
for ( int lr=l; lr<=r; lr++ ) {
if ( a[z[lr]]>0 ) {
a[z[lr]]-=x;
if ( a[z[lr]]<=0 ) {
ans[z[lr]]=i;
}
}
}
}
}
for ( int i=1; i<=n; i++ ) {
if ( ans[i]==0 ) {
cout << "NIE";
endl;
}
else {
cout << ans[i];
endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
402 ms |
6600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
336 ms |
6660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1285 ms |
6876 KB |
Output is correct |
2 |
Incorrect |
13 ms |
8536 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
971 ms |
6604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6025 ms |
7512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6029 ms |
7516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |