Submission #434895

#TimeUsernameProblemLanguageResultExecution timeMemory
434895jeqchoBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
1 ms332 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second int const N=1e7+3; int cwcnt[N]; int ccwcnt[N]; ll cw[N]; ll ccw[N]; ll delivery(int n, int k, int L, int p1[]) { vector<ll>p(n); F0R(i,n)p[i]=p1[i]; cwcnt[0]=k; cw[0]=0; FOR(i,1,n+1) { cwcnt[i]=cwcnt[i-1]+1; cw[i]=cw[i-1]; if(cwcnt[i]>k) { cwcnt[i]=1; cw[i]+=p[i-1]*2; } else { cw[i]+=(p[i-1]-p[i-2])*2; } } ccwcnt[0]=k; ccw[0]=0; FOR(i,1,n+1) { ccwcnt[i]=ccwcnt[i-1]+1; ccw[i]=ccw[i-1]; if(ccwcnt[i]>k) { ccwcnt[i]=1; ccw[i]+=(L-p[n-i])*2; } else { ccw[i]+=(p[n-i+1]-p[n-i])*2; } } ll ans=4e18; F0R(i,n+1) { ll cand=cw[i]+ccw[n-i]; ans=min(ans,cand); } F0R(i,n+1) { ll cand=cw[i]+L; if(n-i-k>=0)cand+=ccw[n-i-k]; ans=min(ans,cand); } 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...