/*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 ) {
for ( int lr=l; lr<=m; lr++ ) {
if ( ans[z[lr]]==0 ) {
a[z[lr]]-=x;
if ( a[z[lr]]<=0 ) {
ans[z[lr]]=i;
}
}
}
for ( int lr=1; lr<=r; lr++ ) {
if ( ans[z[lr]]==0 ) {
a[z[lr]]-=x;
if ( a[z[lr]]<=0 ) {
ans[z[lr]]=i;
}
}
}
}
else {
for ( int lr=l; lr<=r; lr++ ) {
if ( ans[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 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6488 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
400 ms |
6612 KB |
Output is correct |
2 |
Correct |
2567 ms |
6928 KB |
Output is correct |
3 |
Correct |
2092 ms |
6740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
914 ms |
6668 KB |
Output is correct |
2 |
Correct |
1410 ms |
6668 KB |
Output is correct |
3 |
Correct |
1436 ms |
6996 KB |
Output is correct |
4 |
Correct |
9 ms |
7000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1254 ms |
6864 KB |
Output is correct |
2 |
Correct |
2178 ms |
6792 KB |
Output is correct |
3 |
Correct |
19 ms |
6488 KB |
Output is correct |
4 |
Correct |
1227 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1921 ms |
6856 KB |
Output is correct |
2 |
Correct |
3655 ms |
6672 KB |
Output is correct |
3 |
Correct |
910 ms |
6600 KB |
Output is correct |
4 |
Correct |
3491 ms |
6796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6035 ms |
7512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6101 ms |
7512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |