# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863323 |
2023-10-20T03:16:26 Z |
imarn |
Meteors (POI11_met) |
C++14 |
|
960 ms |
65536 KB |
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define ll unsigned long long
#define s second
using namespace std;
const int N=3e5+5;
ll fw[N];
void add(int i,ll amt){
for(;i<N;i+=i&-i)fw[i]+=amt;
}
ll qr(int i,ll res=0){
for(;i;i-=i&-i)res+=fw[i];
return res;
}
vector<ll>g[N];
vector<ll>now[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n,m;cin>>n>>m;
ll a[n+1];
ll b[m+1];
ll c[n+1];
for(int i=1;i<=m;i++)cin>>b[i],g[b[i]].pb(i);
for(int i=1;i<=n;i++)cin>>c[i];
int k;cin>>k;
pair<ll,pair<int,int>>q[k+2];q[0]=q[k+1]={0,{1,m}};
for(int i=1;i<=k;i++)cin>>q[i].s.f>>q[i].s.s>>q[i].f;
int l[n+1],r[n+1];
for(int i=1;i<=n;i++)l[i]=0,r[i]=k+1;
while(1){
memset(fw,0,sizeof fw);
int cnt=0;
for(int i=1;i<=n;i++){
if(l[i]==r[i])continue;
cnt++;now[(l[i]+r[i])/2].pb(i);
}if(cnt==0)break;
for(int i=0;i<=k+1;i++){
if(q[i].s.f<=q[i].s.s)add(q[i].s.f,q[i].f),add(q[i].s.s+1,-q[i].f);
else add(q[i].s.f,q[i].f),add(1,q[i].f),add(q[i].s.s+1,-q[i].f);
for(auto it : now[i]){
ll sum=0;
for(auto ij : g[it])sum+=qr(ij);
if(sum>=c[it])r[it]=i;
else l[it]=i+1;
}now[i].clear();
}now[k+1].clear();
}for(int i=1;i<=n;i++){
if(r[i]>k)cout<<"NIE\n";
else cout<<r[i]<<"\n";
}
}
Compilation message
met.cpp: In function 'int main()':
met.cpp:21:8: warning: unused variable 'a' [-Wunused-variable]
21 | ll a[n+1];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16912 KB |
Output is correct |
2 |
Correct |
6 ms |
16732 KB |
Output is correct |
3 |
Correct |
6 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
16988 KB |
Output is correct |
2 |
Correct |
5 ms |
16732 KB |
Output is correct |
3 |
Correct |
7 ms |
16988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
19424 KB |
Output is correct |
2 |
Correct |
108 ms |
22392 KB |
Output is correct |
3 |
Correct |
79 ms |
21580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
20852 KB |
Output is correct |
2 |
Correct |
90 ms |
20772 KB |
Output is correct |
3 |
Correct |
103 ms |
22796 KB |
Output is correct |
4 |
Correct |
25 ms |
20052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
19796 KB |
Output is correct |
2 |
Correct |
136 ms |
22992 KB |
Output is correct |
3 |
Correct |
93 ms |
17748 KB |
Output is correct |
4 |
Correct |
82 ms |
22120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
18488 KB |
Output is correct |
2 |
Correct |
100 ms |
20600 KB |
Output is correct |
3 |
Correct |
63 ms |
18960 KB |
Output is correct |
4 |
Correct |
119 ms |
24016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
820 ms |
47108 KB |
Output is correct |
2 |
Correct |
620 ms |
26444 KB |
Output is correct |
3 |
Correct |
498 ms |
20964 KB |
Output is correct |
4 |
Runtime error |
925 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
766 ms |
44876 KB |
Output is correct |
2 |
Correct |
715 ms |
26416 KB |
Output is correct |
3 |
Correct |
402 ms |
20184 KB |
Output is correct |
4 |
Runtime error |
960 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |