제출 #1284034

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