#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define optimus_prime ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fxd(x) fixed << setprecision(x)
#define all(a) (a.begin() , a.end())
#define popcount(x) __builtin_popcount(x)
#define lwb lower_bound
#define upb upper_bound
#define dl double long
#define ll long long
#define pb push_back
#define sz() size()
#define F first
#define S second
using namespace std;
const ll N = 3e5+9;
const ll inf=1e9+9;
const ll mod=1e9+7;
const ll P = 37;
map <int , int> mp;
ll n , m , q , p[N] , a[N] , ans[N] , sum[N] , timer;
void solve(){
cin >> n >> m;
for (int i = 1 ; i <= m ; i++){
cin >> p[i];
mp[i]=p[i];
}
for (int i = 1 ; i <= n ; i++)cin >> a[i];
cin >> q;
while (q--){
timer++;
ll l , r , x;
cin >> l >> r >> x;
if (l<=r){
for (int i = l ; i <= r ; i++){
if (ans[mp[i]])continue;
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
}
}
}
else {
for (int i = l ; i <= m ; i++){
if (ans[mp[i]])continue;
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
}
}
for (int i = 1 ; i <= r ; i++){
if (ans[mp[i]])continue;
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
}
}
}
}
for (int i = 1; i<= n ; i++){
if (!ans[i])cout << "NIE\n";
else cout << ans[i] << "\n";
}
}
signed main() {
optimus_prime;
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
4444 KB |
Output is correct |
2 |
Correct |
55 ms |
4444 KB |
Output is correct |
3 |
Correct |
45 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
4440 KB |
Output is correct |
2 |
Correct |
15 ms |
4440 KB |
Output is correct |
3 |
Correct |
57 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6014 ms |
6744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6034 ms |
7280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6018 ms |
7000 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6056 ms |
6900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6093 ms |
21664 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6035 ms |
21844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |