이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// time_limit/sol_db_tle1.cpp
#include "overtaking.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define lsb(x) (x) & (-x)
using namespace std;
const int maxN = 1001;
typedef long long ll;
int n, m, x, ord[maxN][maxN];
ll arrive[maxN][maxN], premax[maxN][maxN];
vector <int> ind, w, s;
vector <ll> t;
map <ll, ll> ans[maxN];
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, t = T, w = W, s = S;
vector <int> inds;
for (int i = 0; i < N; ++i) {
arrive[0][i] = T[i];
inds.push_back(i);
}
auto order_buses = [&](int j) {
sort(all(inds), [&](int x, int y) {
return arrive[j][x] < arrive[j][y];
});
for (int i = 0; i < N; ++i) {
ord[j][i] = inds[i];
}
};
for (int j = 1; j < M; ++j) {
ll pre = 0, lpre = 0;
order_buses(j - 1);
for (int i = 0; i < N; ++i) {
if (i && arrive[j - 1][inds[i]] != arrive[j - 1][inds[i - 1]]) {
lpre = pre;
}
arrive[j][inds[i]] = max(arrive[j - 1][inds[i]] + 1ll * W[inds[i]] * (S[j] - S[j - 1]), lpre);
premax[j][i] = pre = max(pre, arrive[j][inds[i]]);
}
}
order_buses(M - 1);
}
ll calc(int j, ll y) {
if (ans[j].count(y)) {
return ans[j][y];
}
if (j == m) {
return ans[j][y] = y;
}
ll curt = y;
while (j < m) {
int l = 0;
int r = n;
while (l < r) {
int q = l + r >> 1;
if (arrive[j - 1][ord[j - 1][q]] < curt) {
l = q + 1;
} else {
r = q;
}
}
curt = max(curt + 1ll * x * (s[j] - s[j - 1]), l? premax[j][l - 1]: 0);
if (curt == l? premax[j][l - 1]: 0) {
return ans[j][y] = calc(j + 1, curt);
} else {
j++;
}
}
return curt;
}
long long arrival_time(long long y)
{
return calc(1, y);
}
컴파일 시 표준 에러 (stderr) 메시지
overtaking.cpp: In function 'll calc(int, ll)':
overtaking.cpp:63:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
63 | int q = l + r >> 1;
| ~~^~~
# | 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... |