제출 #1066753

#제출 시각아이디문제언어결과실행 시간메모리
1066753pcc추월 (IOI23_overtaking)C++17
65 / 100
3586 ms41172 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> #define pll pair<ll,ll> const int mxn = 1010; vector<pll> f[mxn]; ll X; vector<ll> S,T,W; int N,M; void init(int L, int NN, std::vector<long long> TT, std::vector<int> WW, int XX, int MM, std::vector<int> SS){ N = NN,M = MM; for(auto &i:TT)T.push_back(i); for(auto &i:WW)W.push_back(i); for(auto &i:SS)S.push_back(i); X = XX; for(int i = 0;i<N;i++){ f[0].push_back(pll(T[i],W[i])); } sort(f[0].begin(),f[0].end()); for(int i = 1;i<M;i++){ f[i] = f[i-1]; for(auto &j:f[i])j.fs = j.fs+j.sc*(S[i]-S[i-1]); for(int j = 1;j<N;j++)f[i][j].fs = max(f[i][j-1].fs,f[i][j].fs); sort(f[i].begin(),f[i].end()); } #ifdef DEBUG cerr<<"F: "<<endl; for(int i = 0;i<M;i++){ for(auto &j:f[i])cerr<<j.fs<<','<<j.sc<<' '; cerr<<endl; } #endif for(int i = 0;i+1<M;i++){ for(int j = 0;j<N;j++){ f[i][j].sc = f[i][j].fs+f[i][j].sc*(S[i+1]-S[i]); if(j)f[i][j].sc = max(f[i][j].sc,f[i][j-1].sc); } } #ifdef DEBUG cerr<<"F: "<<endl; for(int i = 0;i<M;i++){ for(auto &j:f[i])cerr<<j.fs<<','<<j.sc<<' '; cerr<<endl; } #endif return; } long long arrival_time(long long Y) { ll ans = -1; /* vector<tlll> v; for(int i = 0;i<N;i++){ v.push_back(tlll(T[i],W[i],i)); } v.push_back(tlll(Y,X,N)); sort(v.begin(),v.end()); for(int i = 1;i<M;i++){ for(int j = 0;j<v.size();j++){ auto &[t,w,id] = v[j]; t += w*(S[i]-S[i-1]); } for(int j = 1;j<v.size();j++){ get<0>(v[j]) = max(get<0>(v[j]),get<0>(v[j-1])); } sort(v.begin(),v.end()); } for(int i = 0;i<v.size();i++){ auto &[t,w,id] = v[i]; if(id == N)ans = t; } */ ll now = Y; for(int i = 0;i+1<M;i++){ ll est = now+X*(S[i+1]-S[i]); auto it = lower_bound(f[i].begin(),f[i].end(),pll(now,-1)); if(it == f[i].begin())now = est; else now = max(est,prev(it)->sc); } ans = now; if(now != ans){ cerr<<"WA: ans = "<<ans<<','<<"returned "<<now<<endl; } assert(now == ans); return now; }
#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...