이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "overtaking.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
struct bus {
ll t; int w;
};
vvll t, e, me;
vi pos;
int X;
void sortByTime(vector<bus>& bs) {
sort(all(bs), [](bus a, bus b){return a.t < b.t;});
}
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S)
{
vll nt; vi nw;
set<int> rem;
forR(i, N) if(W[i] <= X) rem.insert(i);
forR(i, N) if(!rem.count(i)) {
nt.push_back(T[i]);
nw.push_back(W[i]);
}
N -= rem.size();
T = nt, W = nw;
t = vvll(M, vll(N)), e = vvll(M-1, vll(N)), me = vvll(M-1, vll(N));
pos = S;
vector<bus> bs;
forR(i, N) {
bs.push_back({T[i], W[i]});
}
forR(i, M-1) {
sortByTime(bs);
forR(j, N) t[i][j] = bs[j].t;
forR(j, N) e[i][j] = bs[j].t + (ll) bs[j].w * (S[i+1] - S[i]);
ll cm = 0;
for(int j = 0; j < N; ){
ll cur = bs[j].t;
int k=j;
for(; k < N && bs[k].t == cur; ++k) {}
REP(l, j, k) bs[l].t = max(e[i][l], cm);
REP(l, j, k) cm = max(cm, e[i][l]);
j = k;
}
}
forR(j, N) t[M-1][j] = bs[j].t;
::X = X;
forR(i, M-1) {
if(N > 0) me[i][0] = e[i][0];
REP(j, 1, N) me[i][j] = max(e[i][j], me[i][j-1]);
}
}
long long arrival_time(long long Y)
{
int M = (int) pos.size(), N = t[0].size();
forR(i, M-1) {
ll ce = Y + (ll) X * (pos[i+1] - pos[i]);
int id = lower_bound(all(t[i]), Y) - t[i].begin();
if(id > 0) ce = max(ce, me[i][id-1]);
Y = ce;
}
return Y;
}
컴파일 시 표준 에러 (stderr) 메시지
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:64:31: warning: unused variable 'N' [-Wunused-variable]
64 | int M = (int) pos.size(), N = t[0].size();
| ^
# | 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... |