# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863324 |
2023-10-20T03:18:11 Z |
imarn |
Meteors (POI11_met) |
C++14 |
|
6000 ms |
26948 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<int>g[N];
vector<int>now[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n,m;cin>>n>>m;
int a[n+1];
int b[m+1];
int 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<int,pair<int,int>>q[k+2];q[0]={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:44:23: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
44 | if(sum>=c[it])r[it]=i;
| ~~~^~~~~~~
met.cpp:21:9: warning: unused variable 'a' [-Wunused-variable]
21 | int a[n+1];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6025 ms |
16732 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6039 ms |
16728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6067 ms |
18012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6038 ms |
18268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6095 ms |
18008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6052 ms |
17756 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6067 ms |
26948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6035 ms |
26700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |