Submission #1057917

#TimeUsernameProblemLanguageResultExecution timeMemory
1057917mc061Overtaking (IOI23_overtaking)C++17
0 / 100
2 ms4700 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5+3; const int M = 5+3; int n, m; int reserve_speed; vector<pair<int64_t, int>> init_by_arrival; int speed[N]; int stations[M]={}; void init(int l, int n_, std::vector<long long> t, std::vector<int> w, int x, int m_, std::vector<int> s) { n = n_; m = m_; reserve_speed = x; for (int i = 0; i < n; ++i) { speed[i] = w[i]; init_by_arrival.emplace_back(t[i], i); } for (int i = 0; i < m; ++i) { stations[i] = s[i]; } speed[n] = reserve_speed; } long long arrival_time(long long Y) { vector<pair<int64_t, int>> by_arrival = init_by_arrival; vector<pair<int64_t, int>> swp; by_arrival.push_back({Y, n}); for (int st = 0; st+1 < m; ++st) { int64_t mx_prev = -3e18; sort(by_arrival.begin(), by_arrival.end(), [&] (auto& a, auto& b) { if (b.first == a.first) return speed[b.second] > speed[a.second]; return a.first < b.first; }); int64_t d = stations[st+1]-stations[st]; for (int i = 0; i < n+1; ++i) { swp.push_back({max(mx_prev, by_arrival[i].first+d*speed[by_arrival[i].second]), by_arrival[i].second}); mx_prev = max(mx_prev, by_arrival[i].first+d*speed[by_arrival[i].second]); } by_arrival.swap(swp); swp.clear(); } for (auto& x : by_arrival) { if (x.second == n) return x.first; } return -1; }
#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...