제출 #887044

#제출 시각아이디문제언어결과실행 시간메모리
887044vjudge1Solar Storm (NOI20_solarstorm)C++14
36 / 100
2051 ms45648 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N=1e6+1; int n, s, k, d[N], pos[N], v[N], nxt[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; } pair<int, int> ans={-1, -1}; for (int i=1; i<=n; ++i){ int cur=i, cnt=s; while (cur!=n+1 && cnt--){ int it=upper_bound(pos+1, pos+n+1, pos[cur]+k)-pos-1; int it2=upper_bound(pos+1, pos+n+1, pos[it]+k)-pos-1; cur=it2+1; } ans=max(ans, {pf[cur-1]-pf[i-1], i}); } vector<int> res; int cur=ans.second, cnt=s; while (cur!=n+1 && cnt--){ int it=upper_bound(pos+1, pos+n+1, pos[cur]+k)-pos-1; res.push_back(it); int it2=upper_bound(pos+1, pos+n+1, pos[it]+k)-pos-1; cur=it2+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...