이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define pb push_back
#define se second
#define fi first
#define all(x) x.begin(), x.end()
#define graph vector<vll>
using namespace std;
const int N = (int)2e5 + 69;
const int mod = (int)1e4 + 7;
const int naser = 3999, tourist = 3816;
int power(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return ans; }
ll n, x, m, l, y, stn;
vll w, s, t;
graph arv, srt,arvsrt;
bool cmp(int a, int b) {
if (arv[stn][a] == arv[stn][b])
return w[a] < w[b];
return arv[stn][a] < arv[stn][b];
}
bool cmp2(int a, int b) {
return arv[stn][a] < b;
}
void init(int L, int N, vll T, vint W, int X, int M, vint S) {
n = N;
t = T;
w.resize(n);
for (int i = 0; i < n; i++)
w[i] = W[i];
x = X;
m = M;
s.resize(m);
for (int i = 0; i < m; i++)
s[i] = S[i];
arv.resize(m, vll(n));
srt.resize(m, vll(n));
arvsrt.resize(m);
vector<ll> tmp;
for (int i = 0; i < n; i++) {
arv[0][i] = t[i];
arvsrt[0].pb(t[i]);
tmp.pb(i);
}
sort(all(arvsrt[0]));
for (int i = 0; i < m - 1; i++) {
stn = i;
sort(all(tmp), cmp);
srt[i] = tmp;
arv[i + 1][srt[i][0]] = arvsrt[i][0] + w[srt[i][0]] * (s[i + 1] - s[i]);
arvsrt[i + 1].pb(arvsrt[i][0] + w[srt[i][0]] * (s[i + 1] - s[i]));
for (int j = 1; j < n; j++) {
int bus = srt[i][j];
int prv = srt[i][j - 1];
ll ex = arv[i][bus] + (s[i + 1] - s[i]) * w[bus];
if (ex > arv[i + 1][prv])
arv[i + 1][bus] = ex;
else
arv[i + 1][bus] = arv[i + 1][prv];
arvsrt[i + 1].pb(arv[i + 1][bus]);
}
}
}
long long arrival_time(long long y) {
ll ans = y;
for (int i = 0; i < m - 1; i++) {
ll ex = ans + (s[i+1] - s[i]) * x;
if (ans <= arvsrt[i][0])
ans = ex;
else {
int idx = lower_bound(all(arvsrt[i]),ans)-arvsrt[i].begin();
int prv = srt[i][idx - 1];
if (ex < arv[i+1][prv])
ans = arv[i+1][prv];
else
ans = ex;
}
}
return ans;
}
//int32_t main() {
//
// init(6, 4, { 20, 10, 40, 0 }, { 5, 20, 20, 30 }, 10, 4, { 0, 1, 3, 6 });
// //init(6, 1, { 5 }, { 20 }, 10, 5, { 0,2,4,5 ,6 });
// while (naser > tourist) {
// ll Y;
// cin >> Y;
// cout << arrival_time(Y) << endl;
// }
//
//}
# | 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... |