제출 #393435

#제출 시각아이디문제언어결과실행 시간메모리
393435wmrmr선물상자 (IOI15_boxes)C++17
10 / 100
1 ms332 KiB
#include <boxes.h> #include <bits/stdc++.h> #define lli long long int using namespace std; const int MAX = 1e7+1; lli l[MAX], r[MAX]; lli delivery(int n, int k, int MOD, int p[]) { for(int i=0;i<n;i++) { l[i] = 2*p[i]; if(k<=i) l[i] += l[i-k]; } for(int i=n-1;i>=0;i--) { lli rev = (MOD-p[i])%MOD; r[i] = 2*rev; if(i+k<n) r[i] += r[i+k]; } lli ret = min( r[0] , l[n-1] ); for(int i=0;i<n-1;i++) ret = min( ret , l[i] + r[i+1] ); lli cyc = MOD; if(k>=n) ret = min( ret , cyc ); else { ret = min( ret , r[k] + cyc ); ret = min( ret , l[n-k-1] + cyc ); } for(int i=0;i+k+1<n;i++) ret = min( ret , l[i] + r[i+k+1] + cyc ); return ret; }
#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...