# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069590 | UmairAhmadMirza | Closing Time (IOI23_closing) | C++17 | 40 ms | 14944 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=3005;
ll Xd[N],Yd[N],Mxd[N],Mnd[N],sim[N];
vector<ll> dst,st;
int max_score(int n, int X, int Y, long long K, vector<int> U,
vector<int> V, vector<int> W)
{
vector<int> wei(n+1,0);
for(int i=0;i<n;i++)
wei[i+1]=W[i];
X++;
Y++;
for(int i=X+1;i<=n;i++)
Xd[i]=Xd[i-1]+wei[i-1];
for(int i=X-1;i>=1;i--)
Xd[i]=Xd[i+1]+wei[i];
for(int i=Y+1;i<=n;i++)
Yd[i]=Yd[i-1]+wei[i-1];
for(int i=Y-1;i>=1;i--)
Yd[i]=Yd[i+1]+wei[i];
for (int i = 1; i <=n; ++i){
Mxd[i]=max(Xd[i],Yd[i]);
Mnd[i]=min(Xd[i],Yd[i]);
sim[i]=sim[i-1]+Mnd[i];
}
ll t=Xd[Y];
for (int i = X; i <=Y; ++i)
dst.push_back(Mxd[i]-Mnd[i]);
sort(dst.begin(), dst.end());
for (int i = 1; i < dst.size(); ++i)
dst[i]+=dst[i-1];
for (int i = 1; i <=n; ++i)
st.push_back(Mnd[i]);
sort(st.begin(), st.end());
for (int i = 1; i < n; ++i)
st[i]+=st[i-1];
int ans=upper_bound(st.begin(), st.end(),K)-st.begin();
for(int l=1;l<=X;l++)
for(int r=Y;r<=n;r++){
ll ot=(X-l)+(r-Y);
ll cost=K-(sim[r]-sim[l-1]);
if(cost<0)
continue;
int cnt=(r-l)+1;
int ind=upper_bound(dst.begin(), dst.end(),cost)-dst.begin();
cnt+=ind;
if(ind==dst.size()){
cost-=dst.back();
cnt+=min(ot,cost/t);
}
ans=max(ans,cnt);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |