이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "overtaking.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1010;
pair<ll, ll> a[N][N];
ll e[N][N], pref[N][N], s[N];
int n, m;
ll X;
void init(int L, int NN, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
n = NN;
m = M;
::X = X;
for (int i = 0;i < m;i++) {
s[i] = S[i];
}
for (int i = 0;i < n;i++) {
a[0][i] = { T[i], W[i] };
}
for (int K = 0;K < m - 1;K++) {
sort(a[K], a[K] + n);
int idx = 0;
ll mx = 0;
for (int i = 0, j;i < n;i = j) {
for (j = i;j < n && a[K][i].first == a[K][j].first;j++) {
pref[K][j] = mx;
a[K + 1][idx++] = { max(a[K][j].first + a[K][j].second * (s[K + 1] - s[K]), mx)
, a[K][j].second };
}
for (j = i;j < n && a[K][i] == a[K][j];j++) {
e[K][j] = a[K][j].first + a[K][j].second * (s[K + 1] - s[K]);
mx = max(mx, e[K][j]);
}
}
}
sort(a[m - 1], a[m - 1] + n);
}
ll arrival_time(ll Y) {
ll now = Y;
for (int i = 0;i < m - 1;i++) {
int idx = lower_bound(a[i], a[i] + n, pair<ll, ll>(now, 0ll)) - a[i];
now = max(pref[i][min(idx, n - 1)], now + X * (s[i + 1] - s[i]));
}
return now;
}
# | 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... |