/**
* LES GREATEABLES BRO TEAM
**/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) (int)x.size()
const bool FLAG = false;
void setIO(const string &f = "");
#define int ll
const int N = 5e5 + 13;
int t[4 * N], u[4 * N];
void push(int x, int lx, int rx) {
if (u[x]) {
int mid = (lx + rx) / 2;
t[2 * x + 1] += u[x] * (mid - lx + 1);
t[2 * x + 2] += u[x] * (rx - mid + 1);
u[2 * x + 1] += u[x];
u[2 * x + 2] += u[x];
u[x] = 0;
}
}
void upd(int l, int r, int v, int x, int lx, int rx) {
if (r < lx || rx < l) return;
if (l <= lx && rx <= r) {
t[x] += v * (rx - lx + 1);
u[x] += v;
return;
}
push(x, lx, rx);
int mid = (lx + rx) / 2;
upd(l, r, v, 2 * x + 1, lx, mid);
upd(l, r, v, 2 * x + 2, mid + 1, rx);
t[x] = t[2 * x + 1] + t[2 * x + 2];
}
int get(int i, int x, int lx, int rx) {
if (rx == lx)
return t[x];
push(x, lx, rx);
int mid = (lx + rx) / 2;
if (i <= mid)
return get(i, 2 * x + 1, lx, mid);
else
return get(i, 2 * x + 2, mid + 1, rx);
}
void solve() {
int n, m;
cin >> n >> m;
vector<int> o(m + 1);
for (int i = 1; i <= m; i++)
cin >> o[i];
vector<int> p(n + 1);
for (int i = 1; i <= n; i++)
cin >> p[i];
int q;
cin >> q;
vector<int> ans(n + 1);
set<int> s[n + 1];
for (int rep = 1; rep <= q; rep++) {
int l, r, x;
cin >> l >> r >> x;
if (l >= r) {
for (int i = l; i <= m; i++) {
p[o[i]] -= x;
s[o[i]].insert(rep);
if (p[o[i]] <= 0 && ans[o[i]] == 0)
ans[o[i]] = sz(s[o[i]]);
}
for (int i = 1; i <= r; i++) {
p[o[i]] -= x;
s[o[i]].insert(rep);
if (p[o[i]] <= 0 && ans[o[i]] == 0)
ans[o[i]] = sz(s[o[i]]);
}
} else {
for (int i = l; i <= r; i++) {
p[o[i]] -= x;
s[o[i]].insert(rep);
if (p[o[i]] <= 0 && ans[o[i]] == 0)
ans[o[i]] = sz(s[o[i]]);
}
}
}
for (int i = 1; i <= n; i++) {
if (!ans[i])
cout << "NIE\n";
else
cout << ans[i] << '\n';
}
}
signed main() {
setIO();
int tt = 1;
if (FLAG) {
cin >> tt;
}
while (tt--) {
solve();
}
return 0;
}
void setIO(const string &f) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen((f + ".in").c_str(), "r")) {
freopen((f + ".in").c_str(), "r", stdin);
freopen((f + ".out").c_str(), "w", stdout);
}
}
Compilation message
met.cpp: In function 'void setIO(const string&)':
met.cpp:117:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
117 | freopen((f + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met.cpp:118:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
118 | freopen((f + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
69 ms |
4472 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
49 ms |
6404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6012 ms |
17196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
338 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1103 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6067 ms |
48480 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
704 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
805 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |