#include <bits/stdc++.h>
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 1e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
return (a.second < b.second);
}
void pre (ll a) {
cout << fixed << setprecision(a);
return;
}
ll n, m, q;
ll ans[N];
vector <ll> v[N];
ll a[N], b[N], cnt[N];
inline void Solution () {
cin >> n >> m;
for (int i = 1; i <= m; ++ i) {
cin >> a[i];
v[a[i]].pb (i);
}
for (int i = 1; i <= n; ++ i) {
cin >> b[i];
}
ll q, t = 1;
cin >> q;
while (q --) {
ll l, r, val;
cin >> l >> r >> val;
if (l < r) {
for (int i = 1; i <= m; ++ i) {
for (int j = 0; j < v[i].size(); ++ j) {
if (l <= v[i][j] && v[i][j] <= r) {
cnt[i] += val;
}
}
if (cnt[i] >= b[i] && !ans[i]) {
ans[i] = t;
}
}
} else {
for (int i = 1; i <= m; ++ i) {
for (int j = 0; j < v[i].size(); ++ j) {
if (l <= v[i][j] || v[i][j] <= r) {
cnt[i] += val;
}
}
if (cnt[i] >= b[i] && !ans[i]) {
ans[i] = t;
}
}
}
t ++;
}
for (int i = 1; i <= n; ++ i) {
if (ans[i]) {
cout << ans[i] << '\n';
continue;
}
cout << "NIE\n";
}
return;
}
int main () {
Zymraq();
Solution ();
exit (0);
}/*
*/
Compilation message
met.cpp: In function 'void Solution()':
met.cpp:68:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for (int j = 0; j < v[i].size(); ++ j) {
| ~~^~~~~~~~~~~~~
met.cpp:80:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
80 | for (int j = 0; j < v[i].size(); ++ j) {
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
23756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
23756 KB |
Output is correct |
2 |
Correct |
18 ms |
23756 KB |
Output is correct |
3 |
Incorrect |
17 ms |
23984 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5158 ms |
25184 KB |
Output is correct |
2 |
Execution timed out |
6074 ms |
25764 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6089 ms |
25376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5689 ms |
25344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5896 ms |
25120 KB |
Output is correct |
2 |
Execution timed out |
6041 ms |
25372 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6040 ms |
34464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6055 ms |
34172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |