이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;
typedef long long ll;
vector<ll> tCur, tNxt;
vector<int> s;
int x, m;
void init(int l, int n, vector<ll> t, vector<int> w, int x1, int m1, vector<int> s1) {
s = s1;
m = m1;
x = x1;
tCur = vector<ll>();
tNxt = vector<ll>();
vector<pair<ll, ll>> busses(n);
for (int i = 0; i < n; i++) {
busses[i] = {t[i], w[i]};
}
sort(busses.begin(), busses.end());
for (int i = 0; i < n; i++) {
ll curTime = busses[i].first;
ll idealNxt = curTime + busses[i].second * (s[1] - s[0]);
auto iter = lower_bound(tCur.begin(), tCur.end(), curTime);
ll id = iter - tCur.begin();
ll mxNxt = id > 0 ? tNxt[id-1] : 0;
ll nxt = max(idealNxt, mxNxt);
if (nxt > mxNxt) {
if (id < tCur.size() && curTime == tCur[id]) {
tNxt[id] = nxt;
}
else {
auto iter2 = upper_bound(tNxt.begin(), tNxt.end(), nxt);
tCur.erase(iter, tCur.begin() + (iter2 - tNxt.begin()));
tNxt.erase(tNxt.begin() + id, iter2);
tCur.insert(iter, curTime);
tNxt.insert(tNxt.begin() + id, nxt);
}
}
}
}
ll arrival_time(ll y) {
ll idealNxt = y + x * (s[1] - s[0]);
ll id = lower_bound(tCur.begin(), tCur.end(), y) - tCur.begin();
ll mxNxt = id > 0 ? tNxt[id-1] : 0;
return max(idealNxt, mxNxt);
}
컴파일 시 표준 에러 (stderr) 메시지
overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:31:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if (id < tCur.size() && curTime == tCur[id]) {
| ~~~^~~~~~~~~~~~~
# | 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... |