#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse,-fgcse-lm")
#pragma GCC optimize("-ftree-pre,-ftree-vrp")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#define ll long long int
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
ll l, r, a, p[ 500111 ], o[ 500111 ], cnt[ 500111 ], ans[ 500111 ];
vector < ll > v[ 500111 ];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll n, m, k;
cin >> n >> m;
for(int i = 1; i <= m; i ++){
cin >> o[ i ];
v[ o[ i ] ].pb(i);
}
for(int i = 1; i <= n; i ++){
cin >> p[ i ];
}
cin >> k;
ll t = 1;
while(k --){
cin >> l >> r >> a;
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 ] += a;
}
if(cnt[ i ] >= p[ 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 ] += a;
}
if(cnt[ i ] >= p[ i ] && !ans[ i ])
ans[ i ] = t;
}
}
t ++;
}
for(int i = 1; i <= n; i ++){
if(ans[ i ])
cout << ans[ i ] << "\n";
else
cout << "NIE\n";
}
// for(int i = 1; i <= n; i ++){
// cout << i << ":" << cnt[ i ] << "\n";
// }
}
Compilation message
met.cpp: In function 'int main()':
met.cpp:57:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int j = 0; j < v[ i ].size(); j ++){
| ~~^~~~~~~~~~~~~~~
met.cpp:66:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int j = 0; j < v[ i ].size(); j ++){
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
12124 KB |
Output is correct |
2 |
Correct |
11 ms |
12128 KB |
Output is correct |
3 |
Correct |
13 ms |
12124 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12132 KB |
Output is correct |
2 |
Correct |
13 ms |
12128 KB |
Output is correct |
3 |
Correct |
15 ms |
12140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4855 ms |
13444 KB |
Output is correct |
2 |
Execution timed out |
6079 ms |
14020 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6079 ms |
13636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5510 ms |
13572 KB |
Output is correct |
2 |
Execution timed out |
6084 ms |
14016 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6081 ms |
13384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6088 ms |
22756 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
6069 ms |
22532 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |