Submission #1283876

#TimeUsernameProblemLanguageResultExecution timeMemory
1283876cheskaSolar Storm (NOI20_solarstorm)C++20
10 / 100
1516 ms327680 KiB
#include <bits/stdc++.h> using namespace std; #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 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<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]; } map<pii, int> point; vector<vector<int>> ans(n, vector<int>(2)); for (int j = 1; j <= s; j++) { for (int i = n-1; i >= 0; i--) { 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; 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 (point.count({ans2, s})) { fin.pb(ans2); ans2 = point[{ans2, s}]; s--; } fin.pb(ans2); 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...