제출 #347769

#제출 시각아이디문제언어결과실행 시간메모리
347769PetySolar Storm (NOI20_solarstorm)C++14
100 / 100
915 ms126640 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; int n, dp[21][N]; long long s, k, v[N], d[N], st[N]; int main () { cin >> n >> s>> k; for (int i = 2; i <= n; i++) { cin >> d[i]; d[i] += d[i - 1]; } for (int i = 1; i <= n; i++) { cin >> v[i]; v[i] += v[i - 1]; } for (int i = 1; i <= n; i++) { st[i] = lower_bound(d + 1, d + n + 1, d[i] - k) - d; dp[0][i] = st[st[i]] - 1; } for (int i = 1; (1 << i) <= s; i++) for (int j = 1; j <= n; j++) dp[i][j] = dp[i - 1][dp[i - 1][j]]; long long ans = 0, poz = 0; for (int i = 1; i <= n; i++) { int x = i; for (int j = 0; (1 << j) <= s; j++) if (s & (1 << j)) x= dp[j][x]; if (ans < v[i] - v[x]) { poz = i; ans = v[i] - v[x]; } } vector<int>list; for (int j = 0; j < s && poz; j++) { list.push_back(st[poz]); poz = dp[0][poz]; } reverse(list.begin(), list.end()); cout << list.size() << "\n"; for (auto it : list) cout << it << " "; 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...