#include <bits/stdc++.h>
#include <sstream>
#include <fstream>
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
//WAS CREAtED BY BAISYN MUKHAMMED//
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
#define et "\n"
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ioi ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using namespace std;
const ll M = 1000000007;
ll n,m,k,a[511111],mp[311111],mp1[311111],ans[311111],b[311111],c[311111],p[311111];
//map <ll,ll> ;
vector <ll> v[311111];
void solve() {
cin >> m >> n;
for (int i = 1;i <= n;i++) {
cin >> a[i];
}
for (int i = 1;i <= m;i++) {
cin >> b[i];
mp1[i] = b[i];
ans[i] = -1;
}
cin >> k;
for (int i = 1;i <= k;i++) {
ll l,r,x;
cin >> l >> r >> x;
if (l <= r) {
for (int j = l;j <= r;j++) {
mp[a[j]] += x;
if (b[a[j]] <= mp[a[j]] && ans[a[j]] == -1) {
ans[a[j]] = i;
}
}
}
else {
for (int j = 1;j <= r;j++) {
mp[a[j]] += x;
if (b[a[j]] <= mp[a[j]] && ans[a[j]] == -1) {
ans[a[j]] = i;
}
}
for (int j = l;j <= n;j++) {
mp[a[j]] += x;
if (mp1[a[j]] <= mp[a[j]] && ans[a[j]] == -1) {
ans[a[j]] = i;
}
}
}
// cout << et;
}
for (int i = 1;i <= m;i++) {
if (ans[i] == -1) {
cout << "NIE" << et;
}
else {
cout << ans[i] << et;
}
}
}
int main () {
ioi;
// freopen("promote.in","r",stdin);
// freopen("promote.out","w",stdout);
ll t = 1;
// cin >> t;
while (t--) {
// cout << "Case " << t1 << ':' << et;
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16984 KB |
Output is correct |
2 |
Correct |
3 ms |
16988 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
16988 KB |
Output is correct |
2 |
Correct |
4 ms |
17016 KB |
Output is correct |
3 |
Correct |
4 ms |
16988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1510 ms |
17060 KB |
Output is correct |
2 |
Correct |
2637 ms |
17236 KB |
Output is correct |
3 |
Correct |
2494 ms |
17148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1111 ms |
17236 KB |
Output is correct |
2 |
Correct |
1708 ms |
17112 KB |
Output is correct |
3 |
Correct |
4038 ms |
17244 KB |
Output is correct |
4 |
Correct |
10 ms |
17244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1705 ms |
17064 KB |
Output is correct |
2 |
Correct |
2605 ms |
17252 KB |
Output is correct |
3 |
Correct |
25 ms |
16984 KB |
Output is correct |
4 |
Correct |
1493 ms |
17232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2906 ms |
17044 KB |
Output is correct |
2 |
Correct |
4560 ms |
17128 KB |
Output is correct |
3 |
Correct |
1077 ms |
17064 KB |
Output is correct |
4 |
Correct |
4053 ms |
17488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6024 ms |
21844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6032 ms |
21596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |