Submission #395781

#TimeUsernameProblemLanguageResultExecution timeMemory
395781ScarletSBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms208 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int INF = 2e9+7; ll delivery(int n, int k, int l, int p[]) { int x=0,y=n-1,cur,a,b; ll ans=0; while (x<=y) { cur=INF;a=69;b=420; if (y-x+1<=k) { for (int i=x;i<y;++i) cur=min(cur,(p[i]+l-p[i+1])*2); cur=min({cur,l,p[y]*2,(l-p[x])*2}); ans+=cur; break; } for (int i=0;i<k-1;++i) if (cur>min(l,p[x+i]*2)+min(l,(l-p[y-k+i+2])*2)) { cur=min(l,p[x+i]*2)+min(l,(l-p[y-k+i+2])*2); a=x+i+1; b=y-k+i+1; } if (cur>min(l,p[x+k-1]*2)) { cur=min(l,p[x+k-1]*2); a=x+k; b=y; } if (cur>min(l,(l-p[y-k+1])*2)) { cur=min(l,(l-p[y-k+1])*2); a=x; b=y-k; } //cout<<cur<<" "<<a<<" "<<b<<"\n"; ans+=cur; x=a; y=b; } return ans; } // int main() // { // int n,k,l; // cin>>n>>k>>l; // int p[n]; // for (int i=0;i<n;++i) // cin>>p[i]; // cout<<delivery(n,k,l,p); // }
#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...