#include <bits/stdc++.h>
#define respagold ios_base::sync_with_stdio(0), cin.tie(0);
#define ll long long
#define int long long
#define int2 __int128_t
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define pii pair <int, int>
#define mkp make_pair
using namespace std;
const int N = 3e5 + 123;
const int inf = 2e18;
const int MOD1 = 1e9 + 7;
const int MOD = 998244353;
const int P = 6547;
int a[N], b[N], n, m, k, L, R, x, y, z, w, ans[N];
string s;
mt19937 rng( chrono::steady_clock::now().time_since_epoch().count());
int rand( int l, int r )
{
uniform_int_distribution <int> uid( l, r );
return uid( rng );
}
void solve()
{
cin >> n >> m;
FOR( i, 1, m, 1 ) cin >> a[i];
FOR( i, 1, n, 1 ) cin >> b[i];
cin >> k;
FOR( i, 1, k, 1 )
{
cin >> x >> y >> w;
if( x > y )
{
FOR( j, x, m, 1 ) b[a[j]] -= w;
FOR( j, 1, y, 1 ) b[a[j]] -= w;
}
else
{
FOR( j, x, y, 1 ) b[a[j]] -= w;
}
FOR( j, 1, n, 1 )
{
if( b[j] <= 0 && ans[j] == 0 ) ans[j] = i;
}
}
FOR( i, 1, n, 1 )
{
if( ans[i] == 0 ) cout << "NIE\n";
else cout << ans[i] << '\n';
}
}
signed main()
{
// freopen("connect.in", "r", stdin);
// freopen("connect.out", "w", stdout);
respagold
int test = 1;
if( !test ) cin >> test;
while( test -- )
{
solve();
}
}
// solved by KluydQ
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |