# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
480287 |
2021-10-15T13:49:11 Z |
FEDIKUS |
Meteors (POI11_met) |
C++17 |
|
2091 ms |
65536 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(int i=s;i<f;i++)
#define fb(i,s,f) for(int i=(s)-1;i>=f;i--)
#define ffi(i,s,f) for(int i=s;i<=f;i++)
#define fbi(i,s,f) for(int i=s;i>=f;i--)
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,int) sort(a.begin(),a.end(),greater<int>())
#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<int,int> pii;
typedef pair<int,int> pint;
typedef string str;
const int maxn=3e5+10;
vector<int> s[maxn],buckets[maxn];
int p[maxn],res[maxn],l[maxn],r[maxn];
ll bit[maxn];
int lb[maxn],rb[maxn],incr[maxn];
int n,m;
void add(int x,int k){
for(;x<=m;x+=x&-x) bit[x]+=k;
}
ll query(int x){
ll ret=0;
for(;x>0;x-=x&-x) ret+=bit[x];
return ret;
}
void solve(){
cin>>n>>m;
ffi(i,1,m){
int a; cin>>a;
s[a].pb(i);
}
ffi(i,1,n) cin>>p[i];
int k; cin>>k;
ffi(i,1,k) cin>>lb[i]>>rb[i]>>incr[i];
ffi(i,1,n){
l[i]=1;
r[i]=k;
res[i]=-1;
}
bool change=true;
while(true){
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(lb[i]<=rb[i]){
add(lb[i],incr[i]);
add(rb[i]+1,-incr[i]);
}else{
add(1,incr[i]);
add(rb[i]+1,-incr[i]);
add(lb[i],incr[i]);
}
for(int j:buckets[i]){
ll tren=0;
for(int 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;
int t=1;
//cin>>t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
16776 KB |
Output is correct |
2 |
Correct |
15 ms |
16844 KB |
Output is correct |
3 |
Correct |
13 ms |
16716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
16744 KB |
Output is correct |
2 |
Correct |
15 ms |
16744 KB |
Output is correct |
3 |
Correct |
12 ms |
16844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
18116 KB |
Output is correct |
2 |
Correct |
136 ms |
20268 KB |
Output is correct |
3 |
Correct |
129 ms |
19808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
112 ms |
19244 KB |
Output is correct |
2 |
Correct |
120 ms |
19200 KB |
Output is correct |
3 |
Correct |
120 ms |
20340 KB |
Output is correct |
4 |
Correct |
38 ms |
18636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
18628 KB |
Output is correct |
2 |
Correct |
112 ms |
20824 KB |
Output is correct |
3 |
Correct |
60 ms |
17432 KB |
Output is correct |
4 |
Correct |
112 ms |
20172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
17700 KB |
Output is correct |
2 |
Correct |
105 ms |
19268 KB |
Output is correct |
3 |
Correct |
86 ms |
18116 KB |
Output is correct |
4 |
Correct |
134 ms |
21568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1163 ms |
34240 KB |
Output is correct |
2 |
Correct |
649 ms |
21512 KB |
Output is correct |
3 |
Correct |
253 ms |
19752 KB |
Output is correct |
4 |
Correct |
1894 ms |
62072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1099 ms |
32836 KB |
Output is correct |
2 |
Correct |
707 ms |
21600 KB |
Output is correct |
3 |
Correct |
221 ms |
19168 KB |
Output is correct |
4 |
Correct |
2091 ms |
65536 KB |
Output is correct |