Submission #1016426

#TimeUsernameProblemLanguageResultExecution timeMemory
101642612345678Overtaking (IOI23_overtaking)C++17
65 / 100
3535 ms57456 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int nx=1e3+5; ll n, m, e[nx][nx], t[nx][nx], sz, x; vector<ll> l, w, s; vector<pair<ll, ll>> dp[nx]; 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, x=X; s.resize(m); for (int i=0; i<n; i++) if (W[i]>X) l.push_back(T[i]), w.push_back(W[i]); for (int i=0; i<m; i++) s[i]=S[i]; sz=l.size(); for (int i=0; i<sz; i++) t[0][i]=l[i]; for (int i=1; i<m; i++) { vector<pair<ll, pair<ll, ll>>> v; for (int j=0; j<sz; j++) e[i][j]=t[i-1][j]+(s[i]-s[i-1])*w[j], v.push_back({t[i-1][j], {e[i][j], j}}); sort(v.begin(), v.end()); ll mx=0; for (int j=0; j<sz; j++) mx=max(mx, v[j].second.first), t[i][v[j].second.second]=mx; } for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) dp[i].push_back({t[i][j], t[i][j]+(s[i+1]-s[i])*w[j]}); for (int i=0; i<m-1; i++) sort(dp[i].begin(), dp[i].end()); for (int i=0; i<m-1; i++) for (int j=1; j<sz; j++) dp[i][j].second=max(dp[i][j].second, dp[i][j-1].second); //for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) cout<<"dp "<<i<<' '<<j<<' '<<dp[i][j].first<<' '<<dp[i][j].second<<'\n'; } long long arrival_time(long long Y) { ll res=Y; //cout<<"dp\n"; //for (int i=0; i<sz; i++) cout<<dp[1][i].first<<' '<<dp[1][i].second<<'\n'; for (int i=0; i<m-1; i++) { auto itr=lower_bound(dp[i].begin(), dp[i].end(), make_pair(res, LLONG_MIN)); res=res+(s[i+1]-s[i])*x; if (itr!=dp[i].begin()) res=max(res, prev(itr)->second); //cout<<"debug "<<i<<' '<<res<<'\n'; } return res; }
#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...