제출 #831474

#제출 시각아이디문제언어결과실행 시간메모리
831474waldi선물상자 (IOI15_boxes)C++17
0 / 100
1 ms304 KiB
#include<bits/stdc++.h> #define FOR(i,p,k) for(int i=(p);i<=(k);++i) #define REP(i,n) FOR(i,0,(n)-1) typedef long long ll; using namespace std; ll delivery(int n, int k, int l, int poz[]){ ll wyn = n*l; FOR(off, 1, min(n, k)){ ll twyn = 0ll; for(int i = off-1; 1; i += k){ int poc = poz[max(i-k+1, 0)]; int kon = poz[min(i, n-1)]; if(kon <= l>>1) twyn += kon<<1; else if(poc >= (l+1)>>1) twyn += (l-poc)<<1; else twyn += l; if(i >= n-1) break; } wyn = min(wyn, twyn); } return wyn; } #ifdef LOCAL #define maxn 1000 int main(){ int n, k, l, p[maxn]; scanf("%d%d%d", &n, &k, &l); REP(i, n) scanf("%d", &p[i]); ll wyn = delivery(n, k, l, p); printf("%lld\n", wyn); } #endif
#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...