이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 5+3;
const int M = 5+3;
int n, m;
int reserve_speed;
vector<pair<int64_t, int>> init_by_arrival;
int speed[N];
int stations[M]={};
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_;
reserve_speed = x;
for (int i = 0; i < n; ++i) {
speed[i] = w[i];
init_by_arrival.emplace_back(t[i], i);
}
for (int i = 0; i < m; ++i) {
stations[i] = s[i];
}
speed[n] = reserve_speed;
}
long long arrival_time(long long Y) {
vector<pair<int64_t, int>> by_arrival = init_by_arrival;
vector<pair<int64_t, int>> swp;
by_arrival.push_back({Y, n});
for (int st = 0; st+1 < m; ++st) {
int64_t mx_prev = -3e18;
sort(by_arrival.begin(), by_arrival.end(), [&] (auto& a, auto& b) {
if (b.first == a.first) return speed[b.second] > speed[a.second];
return a.first < b.first;
});
int64_t d = stations[st+1]-stations[st];
for (int i = 0; i < n+1; ++i) {
swp.push_back({max(mx_prev, by_arrival[i].first+d*speed[by_arrival[i].second]), by_arrival[i].second});
mx_prev = max(mx_prev, by_arrival[i].first+d*speed[by_arrival[i].second]);
}
by_arrival.swap(swp);
swp.clear();
}
for (auto& x : by_arrival) {
if (x.second == n) return x.first;
}
return -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... |