제출 #887080

#제출 시각아이디문제언어결과실행 시간메모리
887080vjudge1Solar Storm (NOI20_solarstorm)C++14
36 / 100
167 ms192676 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N=1e6+1, LG=20; int n, s, k, d[N], pos[N], v[N], nxt[LG][N], pf[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> s >> k; for (int i=1; i<n; ++i) cin >> d[i], pos[i+1]=pos[i]+d[i]; for (int i=1; i<=n; ++i) cin >> v[i]; partial_sum(v, v+n+1, pf); if (k==1 && *max_element(d+1, d+n)==2 && *min_element(d+1, d+n)==2){ pair<int, int> ans={-1, -1}; for (int i=1; i<=n; ++i){ int j=min(n, i+s-1); ans=max(ans, {pf[j]-pf[i-1], i}); } int i=ans.second, j=min(n, i+s-1); cout << (j-i+1) << '\n'; for (int t=i; t<=j; ++t) cout << t << ' '; return 0; } for (int i=1; i<=n; ++i){ nxt[0][i]=max(i, nxt[0][i-1]); while (nxt[0][i]<n && pos[nxt[0][i]+1]-pos[i]<=k) ++nxt[0][i]; } for (int lg=1; lg<LG; ++lg){ for (int i=n; i>=1; --i) nxt[lg][i]=nxt[lg-1][nxt[lg-1][i]]; } auto jump=[&](int x, int t) -> int { t=min(t, n); for (int i=0; i<LG; ++i) if (t>>i&1) x=nxt[i][x]; return x; }; pair<int, int> ans={-1, -1}; for (int i=1; i<=n; ++i){ int cur=jump(i, s*2); ans=max(ans, {pf[cur]-pf[i-1], i}); } vector<int> res; int cur=ans.second, cnt=s; while (cur!=n+1 && cnt--){ res.push_back(nxt[0][cur]); cur=nxt[1][cur]+1; } cout << res.size() << '\n'; for (int i:res) cout << i << ' '; 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...