이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e3+5;
ll n, m, e[nx][nx], t[nx][nx], sz, x;
vector<ll> l, w, s;
vector<pair<ll, ll>> dp[nx];
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
n=N, m=M, x=X;
s.resize(m);
for (int i=0; i<n; i++) if (W[i]>X) l.push_back(T[i]), w.push_back(W[i]);
for (int i=0; i<m; i++) s[i]=S[i];
sz=l.size();
for (int i=0; i<sz; i++) t[0][i]=l[i];
for (int i=1; i<m; i++)
{
vector<pair<ll, pair<ll, ll>>> v;
for (int j=0; j<sz; j++) e[i][j]=t[i-1][j]+(s[i]-s[i-1])*w[j], v.push_back({t[i-1][j], {e[i][j], j}});
sort(v.begin(), v.end());
ll mx=0;
for (int j=0; j<sz; j++) mx=max(mx, v[j].second.first), t[i][v[j].second.second]=mx;
}
for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) dp[i].push_back({t[i][j], t[i][j]+(s[i+1]-s[i])*w[j]});
for (int i=0; i<m-1; i++) sort(dp[i].begin(), dp[i].end());
for (int i=0; i<m-1; i++) for (int j=1; j<sz; j++) dp[i][j].second=max(dp[i][j].second, dp[i][j-1].second);
//for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) cout<<"dp "<<i<<' '<<j<<' '<<dp[i][j].first<<' '<<dp[i][j].second<<'\n';
}
long long arrival_time(long long Y)
{
ll res=Y, p=sz-1;
for (int i=0; i<m-1; i++)
{
while (p!=-1&&dp[i][p].first>=res) p--;
res=res+(s[i+1]-s[i])*x;
if (p!=-1) res=max(res, dp[i][p].second);
}
return res;
}
# | 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... |