제출 #990913

#제출 시각아이디문제언어결과실행 시간메모리
990913alex_2008추월 (IOI23_overtaking)C++17
0 / 100
0 ms436 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
vector<vector <pair<ll, int>>> dp;
vector <ll> t;
vector <int> w, s;
int n;
int x;
int l;
int m;
bool cmp(pair<ll, int> x, pair<ll, int> y) {
    if (x.first != y.first) return x.first < y.first;
    if (w[x.second] != w[y.second]) return w[x.second] < w[y.second];
    return x.second < y.second;
}
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
    //dp[i][j] = [1, i] avtoneri simulyaciayi jamanak (j-rd) stanciayum hertakanutyun
    m = M;
    l = L;
    x = X;
    s = S;
    dp.clear(); 
    for (int i = 0; i < N; i++) {
        if (W[i] > x) {
            //cout << "? " << T[i] << " " << W[i] << "\n";
            t.push_back(T[i]);
            w.push_back(W[i]);
            n++;
        }
    }
    dp.resize(m);
    vector <pair<ll, int>> esim;
    for (int i = 0; i < n; i++) {
        dp[0].push_back({ t[i], i });
    }
    sort(dp[0].begin(), dp[0].end(), cmp);
    for (int j = 1; j < m; j++) {
        ll cur_mx = 0;
        for (auto& it : dp[j - 1]) {
            cur_mx = max(cur_mx, it.first + w[it.second] * 1ll * (s[j] - s[j - 1]));
            dp[j].push_back({ cur_mx, it.second });
        }
        sort(dp[j].begin(), dp[j].end(), cmp);
    }
}
ll arrival_time(ll Y) {
    int cur_ind = 0;
    for (auto it : t) {
        if (it < Y) cur_ind++;
    }
    if (cur_ind == 0) {
        return l * 1ll * x;
    }
    ll time = Y;
    for (int i = 1; i < m; i++) {
        time = max(time + (s[i] - s[i - 1]) * 1ll * x, dp[i][cur_ind - 1].first);
        while (cur_ind > 0 && dp[i][cur_ind - 1].first == time) {
            cur_ind--;
        }
        if (cur_ind == 0) {
            return (l - s[i]) * 1ll * x + time;
        }
    }
    return time;
}
/*
int main() {
    init(6, 4, { 20, 10, 40, 0 }, { 5, 20, 20, 30 }, 10, 4, { 0, 1, 3, 6 });
    cout << arrival_time(0) << "\n";
    cout << arrival_time(50) << "\n";
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...