# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843846 | ogkostya | Overtaking (IOI23_overtaking) | C++17 | 3533 ms | 16880 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "overtaking.h"
#include <algorithm>
#include <utility>
std::vector<std::vector<std::pair<long long, long long>>> SS(1001, std::vector<std::pair<long long, long long>>());
struct sort1
{
inline bool operator() (const std::pair<long long, int>& a, const std::pair<long long, int>& b)
{
return (a.first < b.first);
}
};
struct sort2
{
inline bool operator() (const std::pair<long long, long long>& a, const std::pair<long long, long long>& b)
{
if (b.second == a.second)
return a.first < b.first;
return (b.second < a.second);
}
};
void sortVecPair(std::vector<long long>& vecA, std::vector<int>& vecB)
{
std::vector<std::pair<long long, int>> vecC;
vecC.reserve(vecA.size());
for (int i = 0; i < vecA.size(); i++)
{
vecC.push_back(std::make_pair(vecA[i], vecB[i]));
}
std::sort(vecC.begin(), vecC.end(), sort1());
vecA.clear();
vecB.clear();
vecA.reserve(vecC.size());
vecB.reserve(vecC.size());
for (int i = 0; i < vecC.size(); i++)
{
vecA.push_back(vecC[i].first);
vecB.push_back(vecC[i].second);
}
}
int _M;
std::vector<int> _S;
int _X;
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
_X = X;
_M = M;
_S = S;
sortVecPair(T, W);
for (int i = 0; i < N; i++)
{
if (W[i] < X)
continue;
long long a = T[i];
for (int j = 1; j < M; j++)
{
long long b = a + 1LL * (_S[j] - _S[j - 1]) * W[i];
for (int k = 0; k < SS[j].size(); k++)
{
if (SS[j][k].first < a && SS[j][k].second > b)
b = SS[j][k].second;
}
SS[j].push_back(std::make_pair(a, b));
a = b;
}
}
for (int j = 1; j < M; j++)
{
std::sort(SS[j].begin(), SS[j].end(), sort2());
std::vector<std::pair<long long, long long>> sorted;
for (int i = 0; i < SS[j].size(); i++)
{
if (sorted.size() == 0)
sorted.push_back(SS[j][i]);
else
{
if (sorted.back().second == SS[j][i].second)
{
continue;
}
else
{
sorted.push_back(SS[j][i]);
}
}
}
SS[j] = sorted;
}
return;
}
long long arrival_time(long long Y)
{
long long a = Y;
for (int j = 1; j < _M; j++)
{
long long b = a + 1LL * (_S[j]-_S[j-1]) * _X;
for (int k = 0; k < SS[j].size(); k++)
{
if (SS[j][k].second <= b)
break;
if (SS[j][k].first < a)
b = SS[j][k].second;
}
a = b;
}
return a;
}
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... |