# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
480256 |
2021-10-15T11:37:30 Z |
FEDIKUS |
Meteors (POI11_met) |
C++17 |
|
1376 ms |
65540 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define ff(i,s,f) for(ll i=s;i<f;i++)
#define fb(i,s,f) for(ll i=(s)-1;i>=f;i--)
#define ffi(i,s,f) for(ll i=s;i<=f;i++)
#define fbi(i,s,f) for(ll i=s;i>=f;i--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,ll) sort(a.begin(),a.end(),greater<ll>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define ub(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;
typedef string str;
const ll maxn=5e5+10;
vector<ll> s[maxn];
ll p[maxn];
vector<ll> buckets[maxn];
ll res[maxn];
ll l[maxn];
ll r[maxn];
ll bit[maxn];
pair<pii,ll> ev[maxn];
void add(ll x,ll k){
for(;x<maxn;x+=x&-x) bit[x]+=k;
}
ll query(ll x){
ll ret=0;
for(;x>0;x-=x&-x) ret+=bit[x];
return ret;
}
void solve(){
ll n,m; cin>>n>>m;
ffi(i,1,m){
ll a; cin>>a;
s[a].pb(i);
}
ffi(i,1,n) cin>>p[i];
ll k; cin>>k;
ffi(i,1,k) cin>>ev[i].xx.xx>>ev[i].xx.yy>>ev[i].yy;
ffi(i,1,n){
l[i]=1;
r[i]=k;
res[i]=-1;
}
bool change=true;
while(change){
change=false;
ffi(i,1,k) buckets[i].clear();
ffi(i,1,n){
if(l[i]<=r[i]){
change=true;
buckets[(l[i]+r[i])/2].pb(i);
}
}
if(!change) break;
fill(bit,bit+maxn,0);
ffi(i,1,k){
if(ev[i].xx.xx<=ev[i].xx.yy){
add(ev[i].xx.xx,ev[i].yy);
add(ev[i].xx.yy+1,-ev[i].yy);
}else{
add(1,ev[i].yy);
add(ev[i].xx.yy+1,-ev[i].yy);
add(ev[i].xx.xx,ev[i].yy);
}
for(ll j:buckets[i]){
ll tren=0;
for(ll t:s[j]){
tren+=query(t);
if(tren>=p[j]) break;
}
if(tren>=p[j]){
res[j]=i;
r[j]=i-1;
}else l[j]=i+1;
}
}
}
ffi(i,1,n)
if(res[i]!=-1) cout<<res[i]<<"\n";
else cout<<"NIE\n";
}
int main(){
ios;
ll t=1;
//cin>>t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
27760 KB |
Output is correct |
2 |
Correct |
20 ms |
27852 KB |
Output is correct |
3 |
Correct |
21 ms |
27724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
27724 KB |
Output is correct |
2 |
Correct |
19 ms |
27800 KB |
Output is correct |
3 |
Correct |
20 ms |
27820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
30620 KB |
Output is correct |
2 |
Correct |
196 ms |
33908 KB |
Output is correct |
3 |
Correct |
134 ms |
32672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
151 ms |
31792 KB |
Output is correct |
2 |
Correct |
150 ms |
31864 KB |
Output is correct |
3 |
Correct |
190 ms |
34228 KB |
Output is correct |
4 |
Correct |
48 ms |
31076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
30832 KB |
Output is correct |
2 |
Correct |
207 ms |
34572 KB |
Output is correct |
3 |
Correct |
142 ms |
28964 KB |
Output is correct |
4 |
Correct |
139 ms |
33316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
29468 KB |
Output is correct |
2 |
Correct |
169 ms |
31784 KB |
Output is correct |
3 |
Correct |
104 ms |
30008 KB |
Output is correct |
4 |
Correct |
193 ms |
35524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1236 ms |
59688 KB |
Output is correct |
2 |
Correct |
1376 ms |
37284 KB |
Output is correct |
3 |
Correct |
650 ms |
33740 KB |
Output is correct |
4 |
Runtime error |
856 ms |
65540 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1287 ms |
57340 KB |
Output is correct |
2 |
Correct |
888 ms |
37188 KB |
Output is correct |
3 |
Correct |
728 ms |
32632 KB |
Output is correct |
4 |
Runtime error |
778 ms |
65540 KB |
Execution killed with signal 9 |