제출 #1283851

#제출 시각아이디문제언어결과실행 시간메모리
1283851cheskaSolar Storm (NOI20_solarstorm)C++20
10 / 100
2095 ms327680 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> #define ppii pair<int, pii> #define tiii tuple<int, int, int> #define g0 get<0> #define g1 get<1> #define g2 get<2> #define f first #define pb push_back const int N = 1e6+5; const int S = 50; const int MOD = 1e9+7; int ans[N][S], point[N][S]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, s, k; cin >> n >> s >> k; vector<int> a(n); for (int i = 1; i < n; i++) { int j; cin >> j; a[i]=a[i-1]+j; } vector<int> v(n), psv(n); for (int i = 0; i < n; i++) cin >> v[i]; psv[0] = v[0]; for (int i = 1; i < n; i++) { psv[i] = psv[i-1]+v[i]; } for (int i = n-1; i >= 0; i--) { for (int j = 1; j <= s; j++) { int r = upper_bound(a.begin(), a.end(), a[i]+k)-a.begin(); int l = lower_bound(a.begin(), a.end(), a[i]-k)-a.begin(); if (j != 1) point[i][j] = r; else point[i][j] = n; if (r == n) { if (l == 0) ans[i][j] = psv[n-1]; else ans[i][j] = psv[n-1]-psv[l-1]; } else { if (l == 0) ans[i][j] = ans[r][j-1]; else ans[i][j] = ans[r][j-1]+psv[r-1]-psv[l-1]; } } } int ans2 = 0; for (int i = 0; i < n; i++) { if (ans[ans2][s] < ans[i][s]) ans2 = i; } vector<int> fin; while (ans2 != n) { fin.pb(ans2); ans2 = point[ans2][s]; s--; } cout << fin.size() << '\n'; for (int i : fin) cout << i+1 << " "; }
#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...