Submission #1016861

#TimeUsernameProblemLanguageResultExecution timeMemory
1016861tmarcinkeviciusOvertaking (IOI23_overtaking)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;

//void init(int32_t _L, int32_t _N, vector<int64_t> _T, vector<int32_t> _W, int32_t _X, int32_t _M, vector<int32_t> _S);
//long long arrival_time(long long Y);

vector<vector<int64_t>> Expected, Real;
int _L;
int _N;
vector<long long> _T;
vector<int> _W;
int _X;
int _M;
vector<int> _S;

void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
    //W.push_back(X);
    _L = L;
    _N = N;
    _T = T;
    _W = W;
    _X = X;
    _M = M;
    _S = S;

    Expected = vector<vector<int64_t>>(_N);
    Real = vector<vector<int64_t>>(_N);
    for (int i = 0; i < _N; i++)
    {
        Expected[i] = vector<int64_t>(_M);
        Real[i] = vector<int64_t>(_M);

        Expected[i][0] = _T[i];
        Real[i][0] = _T[i];
    }

    for (int i = 1; i < _M; i++)
    {
        long long dis = _S[i] - _S[i - 1];

        for (int j = 0; j < _N; j++)
        {
            Expected[j][i] = Real[j][i - 1] + dis * _W[j];
        }

        for (int j = 0; j < _N; j++)
        {
            Real[j][i] = Expected[j][i];
            for (int z = 0; z < _N; z++)
            {
                if (z == j)
                    continue;

                if (Real[z][i - 1] < Real[j][i - 1])
                {
                    Real[j][i] = max(Real[j][i], Expected[z][i]);
                }
            }
        }
    }
}

long long arrival_time(long long Y)
{
    int myTime = Y;
    set<int> slowerAhead;

    for (int i = 0; i < _N; i++)
    {
        if (_W[i] > _X && _T[i] < Y)
        {
            slowerAhead.insert(i);
        }
    }

    for (int i = 1; i < _M; i++)
    {
        int dis = _S[i] - _S[i - 1];
        int expected = myTime + dis * _X;
        vector<int> removeList;

        for (int j : slowerAhead)
        {
            if (Real[j][i] >= expected)
            {
                expected = Real[j][i];
                removeList.push_back(j);
            }
        }

        for (int j : removeList)
        {
            slowerAhead.erase(j);
        }

        myTime = expected;
    }

    return myTime;
}

/*int32_t main()
{
    int L, N, X, M, Q;
    cin >> L >> N >> X >> M >> Q;
    vector<int64_t> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];

    vector<int32_t> W(N);
    for (int i = 0; i < N; i++)
        cin >> W[i];

    vector<int32_t> S(M);
    for (int i = 0; i < M; i++)
        cin >> S[i];

    vector<int> Y(Q);
    for (int i = 0; i < Q; i++)
        cin >> Y[i];

    init(L, N, T, W, X, M, S);
    vector<int> res(Q);
    for (int i = 0; i < Q; i++)
        res[i] = arrival_time(Y[i]);

    for (int i = 0; i < Q; i++)
        cout << res[i] << '\n';
}*/
#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...