이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "overtaking.h"
using namespace std;
 
typedef long long ll;
 
vector<vector<ll>> tCur, tNxt;
vector<ll> s;
ll x, m;
 
void init(int l1, int n1, vector<ll> t, vector<int> w, int x1, int m1, vector<int> s1) {
    ll l = l1;
    ll n = n1;
    s = vector<ll>(s1.size());
    for (ll i = 0; i < s1.size(); i++) s[i] = s1[i];
    m = m1;
    x = x1;
    tCur = vector<vector<ll>>(m-1);
    tNxt = vector<vector<ll>>(m-1);
    vector<pair<ll, ll>> busses;
    for (ll i = 0; i < n; i++) {
        if (w[i] <= x) continue;
        busses.push_back({t[i], w[i]});
    }
    sort(busses.begin(), busses.end());
    n = busses.size();
 
    for (ll t = 0; t < m-1; t++) {
        for (ll i = 0; i < n; i++) {
            ll curTime = busses[i].first;
            if (t > 0) {
                ll idealNxt = curTime + busses[i].second * (s[t] - s[t-1]);
                auto iter = lower_bound(tCur[t-1].begin(), tCur[t-1].end(), curTime);
                ll id = iter - tCur[t-1].begin();
                ll mxNxt = id > 0 ? tNxt[t-1][id-1] : 0;
                busses[i].first = curTime = max(idealNxt, mxNxt);
            }
            ll idealNxt = curTime + busses[i].second * (s[t+1] - s[t]);
            auto iter = lower_bound(tCur[t].begin(), tCur[t].end(), curTime);
            ll id = iter - tCur[t].begin();
            ll mxNxt = id > 0 ? tNxt[t][id-1] : 0;
            ll nxt = max(idealNxt, mxNxt);
            if (nxt > mxNxt) {
                if (id < tCur[t].size() && curTime == tCur[t][id]) {
                    if (nxt > tNxt[t][id]) tNxt[t][id] = nxt;
                }
                else {
                    tCur[t].insert(iter, curTime);
                    tNxt[t].insert(tNxt[t].begin() + id, nxt);
                }
            }
        }
    }
    priority_queue<pair<ll, ll>> q;
    vector<ll> tmpCur, tmpNxt;
    for (int t = m-3; t >= 0; t--) {
        tmpCur = tCur[t];
        tmpNxt = tNxt[t];
        tCur[t].clear(); tNxt[t].clear();
        for (int i = 0; i < tmpCur.size(); i++) {
            q.push({-tmpCur[i], tmpNxt[i]});
        }
        for (auto &e : tCur[t+1]) {
            q.push({-(e - x * (s[t+1] - s[t])), e});
        }
        ll idA = 0, idB = 0;
        while (!q.empty()) {
            auto e = q.top(); q.pop();
            ll curTime = -e.first;
            ll idealNxt = curTime + x * (s[t+1] - s[t]);
            while (idA < tmpCur.size() && tmpCur[idA] <= curTime) idA++;
            ll mxNxt = idA > 0 ? tmpNxt[idA-1] : 0;
            ll nxt = max(idealNxt, mxNxt);
            ll idealEnd = nxt + x * (s[m-1] - s[t+1]);
            if (idealNxt >= mxNxt) {
                while (idB < tCur[t+1].size() && tCur[t+1][idB] <= nxt) idB++;
            }
            else {
                while (idB < tCur[t+1].size() && tCur[t+1][idB] < nxt) idB++;
            }
            ll mxEnd = idB > 0 ? tNxt[t+1][idB-1] : 0;
            ll end = max(idealEnd, mxEnd);
            ll id = tCur[t].size() - 1;
            ll mxPre = tNxt[t].size() > 0 ? tNxt[t].back() : 0;
            if (end > mxPre) {
                if (id < tCur[t].size() && curTime == tCur[t][id]) {
                    if (end > tNxt[t][id]) tNxt[t][id] = end;
                }
                else {
                    tCur[t].push_back(curTime);
                    tNxt[t].push_back(end);
                }
            }
        }
    }
}
ll arrival_time(ll y) {
    ll idealNxt = y + x * (s[m-1] - s[0]);
    ll id = lower_bound(tCur[0].begin(), tCur[0].end(), y) - tCur[0].begin();
    ll mxNxt = id > 0 ? tNxt[0][id-1] : 0;
    y = max(idealNxt, mxNxt);
    return y;
}
컴파일 시 표준 에러 (stderr) 메시지
overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:15:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (ll i = 0; i < s1.size(); i++) s[i] = s1[i];
      |                    ~~^~~~~~~~~~~
overtaking.cpp:44:24: 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]
   44 |                 if (id < tCur[t].size() && curTime == tCur[t][id]) {
      |                     ~~~^~~~~~~~~~~~~~~~
overtaking.cpp:61:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int i = 0; i < tmpCur.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~~
overtaking.cpp:73:24: 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]
   73 |             while (idA < tmpCur.size() && tmpCur[idA] <= curTime) idA++;
      |                    ~~~~^~~~~~~~~~~~~~~
overtaking.cpp:79:28: 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]
   79 |                 while (idB < tCur[t+1].size() && tCur[t+1][idB] <= nxt) idB++;
      |                        ~~~~^~~~~~~~~~~~~~~~~~
overtaking.cpp:82:28: 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]
   82 |                 while (idB < tCur[t+1].size() && tCur[t+1][idB] < nxt) idB++;
      |                        ~~~~^~~~~~~~~~~~~~~~~~
overtaking.cpp:91:24: 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]
   91 |                 if (id < tCur[t].size() && curTime == tCur[t][id]) {
      |                     ~~~^~~~~~~~~~~~~~~~
overtaking.cpp:12:8: warning: unused variable 'l' [-Wunused-variable]
   12 |     ll l = l1;
      |        ^| # | 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... |