#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],b[311111],c[311111],p[311111];
map <ll,ll> mp,ans;
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];
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;
}
for (int j = 1;j <= m;j++) {
if (mp[j] >= b[j] && ans[j] == -1) {
ans[j] = i;
}
// cout << mp[j] << ' ' << j << ' ' << ans[j] << et;
}
}
else {
for (int j = 1;j <= r;j++) {
mp[a[j]] += x;
}
for (int j = l;j <= n;j++) {
mp[a[j]] += x;
}
for (int j = 1;j <= m;j++) {
if (mp[j] >= b[j] && ans[j] == -1) {
ans[j] = i;
}
// cout << mp[j] << ' ' << j << ' ' << ans[j] << et;
}
}
// cout << et;
}
for (int i = 1;i <= m;i++) {
// cout << mp[i] << et;
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 |
7 ms |
4444 KB |
Output is correct |
2 |
Correct |
27 ms |
4628 KB |
Output is correct |
3 |
Correct |
18 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
4444 KB |
Output is correct |
2 |
Correct |
28 ms |
4628 KB |
Output is correct |
3 |
Correct |
54 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6077 ms |
5664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6031 ms |
6184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6056 ms |
5668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6081 ms |
4980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6097 ms |
21840 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6047 ms |
20052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |