제출 #225260

#제출 시각아이디문제언어결과실행 시간메모리
225260bukanYohandiSolar Storm (NOI20_solarstorm)C++14
100 / 100
1258 ms126188 KiB
#include <bits/stdc++.h> /* Karya anak bangsa yang paling agung Author : Yohandi or... bukan.. */ #define fs first #define sc second #define pb push_back #define eb emplace_back #define all(a) a.begin(),a.end() #define lb(a,x) (lower_bound(all(a),x)-a.begin()) #define ub(a,x) (upper_bound(all(a),x)-a.begin()) #define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a) #define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d) #define res(a,x,y) for(int a=(int)x;a>=(int)y;--a) #define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d) // Ordered Set, Ordered Multiset #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> using namespace __gnu_pbds; // .order_of_key(x) -> Number of elements less than x // * .find_by_order(k) -> Kth smallest element (0-based) // .erase(x) -> Remove all elements equal to x #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; using lint=long long; mt19937 rng(time(NULL)); lint Power(lint A,lint B,lint C){ if(!B) return 1LL; lint tmp=Power(A,B>>1,C); return tmp*tmp%C*(B&1?A:1)%C; } int T,N,S,Le,Ri,Id; int Par[1111111][21]; lint K,Ans; lint V[1111111],D[1111111]; pair<int,int> P[1111111]; int Ancestor(int U,int Diff){ for(int j=log2(N+1);j>=0;--j){ if(Diff&(1<<j)) U=Par[U][j]; } return U; } int main(){ // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; // cin>>T; rep(t,1,T){ cin>>N>>S>>K; for(int i=1;i<=N-1;++i){ cin>>D[i]; D[i]+=D[i-1]; } for(int i=1;i<=N;++i){ cin>>V[i]; V[i]+=V[i-1]; } Le=1; Ri=1; for(int i=1;i<=N;++i){ while(Le<=i&&D[i-1]-D[Le-1]>K) Le++; while(Ri<=N&&D[Ri-1]-D[i-1]<=K) Ri++; P[Le].fs=Ri; P[Le].sc=i; } for(int i=1;i<=N;++i){ if(P[i].fs==0) P[i]=P[i-1]; } P[N+1]=P[N]; V[N+1]=V[N]; memset(Par,-1,sizeof(Par)); for(int i=1;i<=N+1;++i) Par[i][0]=P[i].fs; for(int j=1;j<=log2(N);++j) for(int i=1;i<=N+1;++i) if(Par[i][j-1]!=-1&&Par[Par[i][j-1]][j-1]!=-1) Par[i][j]=Par[Par[i][j-1]][j-1]; for(int i=1;i<=N;++i){ if(Ans<V[Ancestor(i,S)-1]-V[i-1]){ Ans=V[Ancestor(i,S)-1]-V[i-1]; Id=i; } } cout<<S<<endl; for(int i=1;i<=S;++i){ if(i!=1) cout<<" "; cout<<P[Id].sc; Id=P[Id].fs; } cout<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...