답안 #340404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340404 2020-12-27T14:15:32 Z mihai145 Solar Storm (NOI20_solarstorm) C++14
8 / 100
554 ms 120804 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int NMAX = 1e6;
const long long INF = 1e15;
const int LGMAX = 20;

int N, S;
long long K, d[NMAX + 5], v[NMAX + 5];

int opt[NMAX + 5];
int binaryLift[NMAX + 2][LGMAX + 2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> S >> K;

    d[0] = -INF;
    d[1] = 0;
    for(int i = 2; i <= N; i++)
    {
        cin >> d[i];
        d[i] += d[i - 1];
    }

    v[0] = 0;
    for(int i = 1; i <= N; i++)
    {
        cin >> v[i];
        v[i] += v[i - 1];
    }

    int j = 0;
    for(int i = 1; i <= N; i++)
    {
        while(j < i && d[i] - d[j] > K)
            j++;

        opt[i] = j;
        binaryLift[i][0] = j - 1;
    }

    for(int step = 1; step <= LGMAX; step++)
        for(int i = 1; i <= N; i++)
            binaryLift[i][step] = binaryLift[opt[binaryLift[i][step - 1]]][step - 1];

    pair <long long, pair<int, int>> bst = {-1, {0, 0}};

    for(int rg = 1; rg <= N; rg++)
    {

        int s = S, lf = rg;

        for(int step = LGMAX; step >= 0; step--)
            if(s >= (1 << step))
            {
                lf = binaryLift[lf][step];
                s -= (1 << step);
            }

        bst = max(bst, {v[rg] - v[lf], {lf, rg}});
    }

    vector <int> sol;

    int curr = bst.second.second;
    while(curr > bst.second.first)
    {
        sol.push_back(opt[curr]);
        curr = binaryLift[opt[curr]][0];
    }

    reverse(sol.begin(), sol.end());

    cout << (int)sol.size() << '\n';
    for(auto it : sol)
        cout << it << ' ';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 3 ms 1388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 359 ms 98540 KB Output is correct
2 Incorrect 230 ms 62700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 3 ms 1388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 423 ms 98480 KB Output is correct
2 Correct 232 ms 58476 KB Output is correct
3 Correct 241 ms 62696 KB Output is correct
4 Correct 344 ms 90476 KB Output is correct
5 Correct 332 ms 87788 KB Output is correct
6 Correct 353 ms 93036 KB Output is correct
7 Correct 554 ms 120804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 3 ms 1388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 3 ms 1388 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 3 ms 1388 KB Output isn't correct
3 Halted 0 ms 0 KB -