# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844076 | ogkostya | Overtaking (IOI23_overtaking) | C++17 | 3567 ms | 18012 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)
{
if (a.first == b.first)
return a.second < b.second;
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)
{
return a.first < b.first;
}
};
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;
std::vector<std::pair<long long, int>> TW;
TW.reserve(N);
for (int i = 0; i < N; i++)
{
if (W[i] < X)
continue;
TW.push_back(std::make_pair(T[i], W[i]));
}
std::sort(TW.begin(), TW.end(), sort1());
for (int j = 1; j < M; j++)
{
std::sort(TW.begin(), TW.end(), sort1());
long long mb = 0;
for (int i = 0; i < TW.size(); i++)
{
long long a = TW[i].first;
long long b = a + 1LL * (_S[j] - _S[j - 1]) * TW[i].second;
if (b < mb)
b = mb;
if (SS[j].size() == 0 || SS[j].back().second != b)
{
SS[j].push_back(std::make_pair(a, b));
}
TW[i].first = b;
if (b > mb)
mb = b;
a = b;
}
}
}
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;
if (SS[j].size() > 0 && SS[j][0].first < a)
{
int l = 0, r = SS[j].size();
while (l < r)
{
int m = (l + r + 1) / 2;
if (m == SS[j].size())
{
break;
}
else if (SS[j][m].first < a)
{
l = m;
}
else
{
r = m - 1;
}
}
if (l < SS[j].size() && b < SS[j][l].second)
b = SS[j][l].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... |