제출 #980923

#제출 시각아이디문제언어결과실행 시간메모리
980923vjudge1추월 (IOI23_overtaking)C++17
0 / 100
1 ms6596 KiB
// hola soy Dember :D // 31/03/2024 #include <bits/stdc++.h> #include "overtaking.h" #define ll long long #define pll pair<ll,ll> //#define F first //#define S second #define Z size() #define pb push_back #define bp pop_back #define fo(x,y,z) for(ll x=y; x<=z; x++) #define of(x,y,z) for(ll x=y; x>=z; x--) #define all(n) n.begin(), n.end() #define arr(x,y,z) x+y, x+y+z using namespace std; const int MN=1e3+3; ll n, m, xd, zd, ans, l, r; ll a[MN], b[MN][MN], f[MN][MN], g[MN][MN]; vector<ll> t; vector<int> w,s; void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S){ n=N; m=M; t=T, w=W, s=S;w.pb(X); fo(i,0,n-1)a[i]=i, f[i][0]=t[i]; fo(j,1,m-1){ sort(arr(a,0,n), [&] (const int &x, const int &y){ if(f[x][j-1]!=f[y][j-1])return f[x][j-1]<f[y][j-1]; return w[x]<w[y]; }); xd=0; fo(h,0,n-1){ ll i=a[h]; f[i][j]=max(xd, f[i][j-1]+w[i]*(s[j]-s[j-1])); xd=f[i][j]; } } fo(j,1,m-1){ sort(arr(a,0,n), [&] (const int &x, const int &y){ if(f[x][j-1]!=f[y][j-1])return f[x][j-1]<f[y][j-1]; return w[x]<w[y]; }); fo(h,0,n-1){ ll i=a[h]; g[j][h]=f[i][j]; if(h)g[j][h]=max(g[j][h], g[j][h-1]); } fo(i,0,n-1)b[i][j]=a[i]; } return; } ll arrival_time(long long Y) { ans=Y; fo(j,1,m-1){ l=0, r=n-1, zd=-1; while (l <= r) { xd=(l+r)/2; if (ans>f[b[xd][j]][j-1])zd=xd,l=xd+1; else r=xd-1; } xd=ans+w[n]*(s[j]-s[j-1]); if(zd!=-1)xd=max(xd, g[j][zd]); ans=xd; //cout<<ans<<" "; } return ans; }
#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...