# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
496478 | AQ0212 | Meteors (POI11_met) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>
#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(false); cout.tie(false);
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";
// }
}