#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
#define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 5e5 + 101;
const int md = 998244353;
const int mod = 1e9 + 7;
const int mega = 1e6 + 3;
const int inf = 1e18;
ll gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
int binpow(int a, int b, int m = mod) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
void solve(){
int n , m;
cin >> n >> m;
int a[m + 1];
for(int i = 1; i <= m; ++i)cin >> a[i];
int p[n + 1];
for(int i = 1; i <= n; ++i)cin >> p[i];
int k;
cin >> k;
vector<int>mp(n + 1 , 0) , ans(n + 1 , 0);
for(int j = 1; j <= k; ++j){
int l , r;
cin >> l >> r;
int x;
cin >> x;
if(l <= r){
for(int i = l; i <= r; i++){
mp[a[i]] += x;
if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
}
}
else{
for(int i = l; i <= m; ++i){
mp[a[i]] += x;
if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
}
// for(int i = 1; i <= n; ++i){
// if(mp[i] >= p[i])ans[i] = j;
// }
for(int i = 1; i <= r; ++i){
mp[a[i]] += x;
if(mp[a[i]] >= p[a[i]] && ans[a[i]] == 0)ans[a[i]] = j;
}
// for(int i = 1; i <= n; ++i){
// if(mp[i] >= p[i])ans[i] = j;
// }
}
}
for(int i = 1; i <= n; ++i){
if(mp[i] < p[i])cout << "NIE";
else {
// cout << mp[i] << nl;
cout << ans[i];
}
cout << nl;
}
}
signed main() {
// SPEED;
int t = 1;
// cin >> t;
while (t--) {
solve();
}
#ifndef ONLINE_JUDGE
cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
775 ms |
932 KB |
Output is correct |
2 |
Correct |
3073 ms |
1396 KB |
Output is correct |
3 |
Correct |
2082 ms |
1124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
996 ms |
1004 KB |
Output is correct |
2 |
Correct |
1320 ms |
1028 KB |
Output is correct |
3 |
Correct |
4436 ms |
1392 KB |
Output is correct |
4 |
Correct |
13 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1691 ms |
916 KB |
Output is correct |
2 |
Correct |
2088 ms |
1372 KB |
Output is correct |
3 |
Correct |
31 ms |
344 KB |
Output is correct |
4 |
Correct |
1223 ms |
1204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2746 ms |
808 KB |
Output is correct |
2 |
Correct |
4297 ms |
1048 KB |
Output is correct |
3 |
Correct |
1043 ms |
836 KB |
Output is correct |
4 |
Correct |
3234 ms |
1368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6100 ms |
4944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6027 ms |
4688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |