# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865081 |
2023-10-24T05:23:38 Z |
vjudge1 |
Meteors (POI11_met) |
C++17 |
|
6000 ms |
38736 KB |
#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define optimus_prime ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fxd(x) fixed << setprecision(x)
#define all(a) (a.begin() , a.end())
#define popcount(x) __builtin_popcount(x)
#define lwb lower_bound
#define upb upper_bound
#define dl double long
#define ll long long
#define pb push_back
#define sz() size()
#define F first
#define S second
using namespace std;
const ll N = 3e5+9;
const ll inf=1e9+9;
const ll mod=1e9+7;
const ll P = 37;
map <int , int> mp;
ll n , m , q , p , a[N] , ans[N] , sum[N] , timer , t[N*4];
vector <int> g[N];
void build(ll v=1 , ll tl=1 , ll tr=m){
if (tl==tr){
t[v]=1;
return;
}
ll tm=(tl+tr)>>1;
build(v*2 , tl , tm);
build(v*2|1 , tm+1 , tr);
t[v]=t[v*2]+t[v*2|1];
}
ll get(ll l , ll r , ll v=1 , ll tl=1 , ll tr=m){
if (l<=tl&&tr<=r)return t[v];
if (r<tl||tr<l)return 0;
ll tm=(tl+tr)>>1;
return get(l , r , v*2 , tl , tm)+get(l , r , v*2|1 , tm+1 , tr);
}
void upd(ll pos , ll v=1 , ll tl=1 , ll tr=m){
if (tl==tr){
t[v]=0;
return;
}
ll tm=(tl+tr)>>1;
if (pos<=tm)upd(pos , v*2 , tl , tm);
else upd(pos , v*2|1 , tm+1 , tr);
}
void solve(){
cin >> n >> m;
for (int i = 1 ; i <= m ; i++){
cin >> p;
mp[i]=p;
g[p].pb(i);
}
for (int i = 1 ; i <= n ; i++)cin >> a[i];
build();
cin >> q;
while (q--){
timer++;
ll l , r , x;
cin >> l >> r >> x;
if (l<=r){
if (get(l , r)){
for (int i = l ; i <= r ; i++){
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
for (auto to : g[mp[i]])upd(to);
}
}
}
}
else {
if (get(l , m)){
for (int i = l ; i <= m ; i++){
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
for (auto to : g[mp[i]])upd(to);
}
}
}
if (get(1 , r)){
for (int i = 1 ; i <= r ; i++){
sum[mp[i]]+=x;
if (sum[mp[i]]>=a[mp[i]]&&!ans[mp[i]]){
ans[mp[i]]=timer;
for (auto to : g[mp[i]])upd(to);
}
}
}
}
}
for (int i = 1; i<= n ; i++){
if (!ans[i])cout << "NIE\n";
else cout << ans[i] << "\n";
}
}
signed main() {
optimus_prime;
ll t=1;
while (t--)solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
12892 KB |
Output is correct |
2 |
Correct |
44 ms |
12892 KB |
Output is correct |
3 |
Correct |
68 ms |
12892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
12892 KB |
Output is correct |
2 |
Correct |
69 ms |
12892 KB |
Output is correct |
3 |
Correct |
67 ms |
12888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6028 ms |
15452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6047 ms |
15952 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6054 ms |
15676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6041 ms |
15448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6063 ms |
38736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6053 ms |
38636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |