| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1277266 | ducdev | Solar Storm (NOI20_solarstorm) | C++17 | 257 ms | 160804 KiB | 
// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e6;
const int MOD = 1e9 + 7;
const int INF = 2e9;
int n, s;
int d[MAX_N + 5], v[MAX_N + 5];
ll k;
ll pref[MAX_N + 5];
ll getSum(int l, int r) {
    if (l > r) return 0;
    return pref[r] - (l == 0 ? 0 : pref[l - 1]);
};
namespace SUBTASK_12356 {
    const int LIM = 1e8;
    const int N = MAX_N + 1;
    int L[N + 5], R[N + 5], nextPos[N + 5];
    int depth[N + 5];
    int traceIdx;
    vector<int> nodes;
    ll res;
    vector<int> adj[N + 5];
    void dfs(int u) {
        nodes.push_back(u);
        int l = L[u], r = R[nodes[max(0, depth[u] - s)]];
        if (res < getSum(l, r)) {
            res = getSum(l, r);
            traceIdx = u;
        };
        for (int v : adj[u]) {
            depth[v] = depth[u] + 1;
            dfs(v);
        };
        nodes.pop_back();
    };
    void Solve() {
        ll dist = 0;
        for (int i = 1; i <= n; i++) {
            L[i] = max(1, L[i - 1]);
            while (L[i] < i && dist > k) {
                dist -= d[L[i]];
                L[i]++;
            };
            dist += d[i];
        };
        dist = 0;
        R[n] = n;
        for (int i = n - 1; i >= 1; i--) {
            dist += d[i];
            R[i] = R[i + 1];
            while (R[i] > i && dist > k) {
                dist -= d[R[i] - 1];
                R[i]--;
            };
        };
        for (int i = 1; i <= n; i++) {
            nextPos[i] = max(i, nextPos[i - 1]);
            while (nextPos[i] < n && L[nextPos[i] + 1] <= R[i] + 1) nextPos[i]++;
            if (nextPos[i] == i) nextPos[i] = n + 1;
            adj[nextPos[i]].push_back(i);
        };
        depth[n + 1] = 1;
        dfs(n + 1);
        vector<int> trace;
        while (true) {
            s--;
            trace.push_back(traceIdx);
            if (nextPos[traceIdx] == n + 1 || s == 0) break;
            traceIdx = nextPos[traceIdx];
        };
        cout << trace.size() << '\n';
        for (int idx : trace) cout << idx << ' ';
    };
};  // namespace SUBTASK_12356
namespace SUBTASK_4 {
    const int N = MAX_N;
    bool checkSubtask() {
        for (int i = 1; i < n; i++)
            if (d[i] != 2) return false;
        return k == 1;
    };
    void Solve() {
        ll sum = 0, res = 0;
        int l = 0, r = 0;
        for (int i = 1; i <= n; i++) {
            sum += v[i];
            if (i > s) sum -= v[i - s];
            if (res < sum) {
                res = sum;
                l = max(1, i - s + 1);
                r = i;
            };
        };
        cout << r - l + 1 << '\n';
        for (int i = l; i <= r; i++) cout << i << ' ';
    };
};  // namespace SUBTASK_4
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (fopen("MAIN.INP", "r")) {
        freopen("MAIN.INP", "r", stdin);
        freopen("MAIN.OUT", "w", stdout);
    };
    cin >> n >> s >> k;
    for (int i = 1; i < n; i++) {
        cin >> d[i];
    };
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        pref[i] = pref[i - 1] + v[i];
    };
    SUBTASK_12356::Solve();
};
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
