# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863326 |
2023-10-20T03:19:22 Z |
imarn |
Meteors (POI11_met) |
C++14 |
|
1358 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<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]=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: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 |
Correct |
5 ms |
16732 KB |
Output is correct |
2 |
Correct |
5 ms |
16732 KB |
Output is correct |
3 |
Correct |
5 ms |
16732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
16728 KB |
Output is correct |
2 |
Correct |
5 ms |
16732 KB |
Output is correct |
3 |
Correct |
6 ms |
16988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
18388 KB |
Output is correct |
2 |
Correct |
98 ms |
20304 KB |
Output is correct |
3 |
Correct |
85 ms |
19856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
19284 KB |
Output is correct |
2 |
Correct |
84 ms |
19344 KB |
Output is correct |
3 |
Correct |
109 ms |
20584 KB |
Output is correct |
4 |
Correct |
24 ms |
18768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
18772 KB |
Output is correct |
2 |
Correct |
116 ms |
20928 KB |
Output is correct |
3 |
Correct |
92 ms |
17532 KB |
Output is correct |
4 |
Correct |
81 ms |
20308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
17984 KB |
Output is correct |
2 |
Correct |
97 ms |
19480 KB |
Output is correct |
3 |
Correct |
59 ms |
18260 KB |
Output is correct |
4 |
Correct |
97 ms |
21568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
703 ms |
34968 KB |
Output is correct |
2 |
Correct |
621 ms |
22896 KB |
Output is correct |
3 |
Correct |
491 ms |
20132 KB |
Output is correct |
4 |
Correct |
1184 ms |
62592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
683 ms |
33824 KB |
Output is correct |
2 |
Correct |
645 ms |
22884 KB |
Output is correct |
3 |
Correct |
400 ms |
19272 KB |
Output is correct |
4 |
Correct |
1358 ms |
65536 KB |
Output is correct |