#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define int long long
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
const int E = 1e9;
const long long inf = 1e18+777;
const int N = 3e5+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, m, o[N], p[N];
vector<int> ans(N, -1);
signed main(){
cin >> n >> m;
for(int i = 1; i <= m; ++i){
cin >> o[i];
}
for(int i = 1; i <= n; ++i){
cin >> p[i];
}
// cerr << "P\n";for(int i = 1; i <= n; ++i){
// cerr << p[i] << ' ';
// }cerr << '\n';
int que, cnt = 0; cin >> que;
for(int l, r, a; que--;){
++cnt;
cin >> l >> r >> a;
// cerr << "l: " << l << " r: " << r << " a: " << a<< '\n';
if(l > r){
for(int i = l; i <= m; ++i){
p[o[i]] -= a;
if(p[o[i]] <= 0 && ans[o[i]] == -1){
ans[o[i]] = cnt;
}
}
for(int i = 1; i <= r; ++i){
p[o[i]] -= a;
if(p[o[i]] <= 0 && ans[o[i]] == -1){
ans[o[i]] = cnt;
}
}
}else{
for(int i = l; i <= r; ++i){
p[o[i]] -= a;
if(p[o[i]] <= 0 && ans[o[i]] == -1){
ans[o[i]] = cnt;
}
}
}
}
for(int i = 1; i <= n; ++i){
if(ans[i] == -1) cout << "NIE\n";
else cout << ans[i] << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2636 KB |
Output is correct |
2 |
Correct |
3 ms |
2636 KB |
Output is correct |
3 |
Correct |
4 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2636 KB |
Output is correct |
2 |
Correct |
4 ms |
2636 KB |
Output is correct |
3 |
Correct |
6 ms |
2636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1856 ms |
3084 KB |
Output is correct |
2 |
Correct |
5494 ms |
3248 KB |
Output is correct |
3 |
Correct |
3374 ms |
3148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2232 ms |
3116 KB |
Output is correct |
2 |
Correct |
2739 ms |
3120 KB |
Output is correct |
3 |
Execution timed out |
6054 ms |
3252 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3664 ms |
3084 KB |
Output is correct |
2 |
Correct |
4427 ms |
3244 KB |
Output is correct |
3 |
Correct |
66 ms |
2636 KB |
Output is correct |
4 |
Correct |
2512 ms |
3176 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5845 ms |
3052 KB |
Output is correct |
2 |
Execution timed out |
6059 ms |
3020 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6040 ms |
5700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6042 ms |
5552 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |