#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 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(){NFS;
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){
if(p[o[i]] > 0){
p[o[i]] -= a;
if(p[o[i]] <= 0 && ans[o[i]] == -1){
ans[o[i]] = cnt;
}
}
}
for(int i = 1; i <= r; ++i){
if(p[o[i]] > 0){
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){
if(p[o[i]] > 0){
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 |
2 ms |
1484 KB |
Output is correct |
2 |
Correct |
2 ms |
1484 KB |
Output is correct |
3 |
Correct |
3 ms |
1484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1484 KB |
Output is correct |
2 |
Correct |
1 ms |
1484 KB |
Output is correct |
3 |
Correct |
3 ms |
1484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
295 ms |
1724 KB |
Output is correct |
2 |
Correct |
5600 ms |
1792 KB |
Output is correct |
3 |
Correct |
2648 ms |
1748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1604 ms |
1744 KB |
Output is correct |
2 |
Correct |
2113 ms |
1740 KB |
Output is correct |
3 |
Correct |
1056 ms |
1788 KB |
Output is correct |
4 |
Correct |
14 ms |
1868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2003 ms |
1708 KB |
Output is correct |
2 |
Correct |
4118 ms |
1788 KB |
Output is correct |
3 |
Correct |
23 ms |
1484 KB |
Output is correct |
4 |
Correct |
2005 ms |
1772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1613 ms |
1692 KB |
Output is correct |
2 |
Correct |
3296 ms |
1740 KB |
Output is correct |
3 |
Correct |
1473 ms |
1696 KB |
Output is correct |
4 |
Correct |
5090 ms |
1916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6093 ms |
3036 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6084 ms |
3020 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |