Submission #564661

#TimeUsernameProblemLanguageResultExecution timeMemory
564661myrcellaBoxes with souvenirs (IOI15_boxes)C++17
20 / 100
72 ms156932 KiB
//by szh #include<bits/stdc++.h> #include "boxes.h" using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long,long long> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl #define pq priority_queue #define inf 0x3f #define rep(i,a,b) for (int i=a;i<(b);i++) #define MP make_pair #define SZ(x) (int(x.size())) #define ll long long #define mod 1000000007 #define ALL(x) x.begin(),x.end() void inc(int &a,int b) {a=(a+b)%mod;} void dec(int &a,int b) {a=(a-b+mod)%mod;} int lowbit(int x) {return x&(-x);} ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;} const int maxn = 1e7+10; ll pre[maxn],suf[maxn]; long long delivery(int N, int K, int L, int p[]) { memset(pre,0,sizeof(pre)); memset(suf,0,sizeof(suf)); rep(i,0,N) { pre[i] = min(p[i]*2,L); int tmp = i%K+1; if (i!=0) pre[i] += pre[i-tmp]; } for(int i=N-1;i>=0;i--) { suf[i] = min((L-p[i])*2,L); int tmp = (N-1-i)%K+1; if (i!=N-1) suf[i] += suf[i+tmp]; } ll ans = min(suf[0],pre[N-1]); rep(i,0,N-1) ans = min (ans,pre[i]+suf[i+1]); 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...