Submission #1064168

#TimeUsernameProblemLanguageResultExecution timeMemory
1064168jer033Overtaking (IOI23_overtaking)C++17
0 / 100
1 ms348 KiB
#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using tlli = tuple<ll, ll, int>;//prev time, next time, index

ll L;
int N;
vector<ll> T;
vector<ll> W;
ll X;
int M;
vector<ll> S;

void init(int L1, int N1, std::vector<long long> T1, std::vector<int> W1, int X1, int M1, std::vector<int> S1)
{
    L = L1;
    N = N1;
    T = T1;
    for (int i: W1)
        W.push_back(i);
    X = X1;
    W.push_back(X);
    M = M1;
    for (int i: S1)
        S.push_back(i);
}

long long arrival_time(long long Y)
{
    T.push_back(Y);
    vector<vector<ll>> times(N+1);
    for (int i=0; i<=N; i++)
        times[i].push_back(T[i]);
    for (int sorting = 1; sorting<M; sorting++)
    {
        ll length = S[sorting] - S[sorting-1];
        vector<tlli> move;
        for (int i=0; i<=N; i++)
        {
            move.push_back({times[i][sorting-1], times[i][sorting-1] + (length*W[i]), i});
        }
        sort(move.begin(), move.end());
        ll running_max = -1;
        for (int j=0; j<=N; j++)
        {
            running_max = max(running_max, get<1>(move[j]));
            int i = get<2>(move[j]);
            times[i].push_back(running_max);
        }
    }
    return times[N][M-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...