제출 #897900

#제출 시각아이디문제언어결과실행 시간메모리
897900ByeWorld선물상자 (IOI15_boxes)C++14
50 / 100
2016 ms18260 KiB
#include "boxes.h" #include <bits/stdc++.h> #define fi first #define se second #define ll long long using namespace std; typedef pair<ll,ll> pii; const ll MAXN = 1e7+10; const ll INF = 2e18+10; int n, k, l; int a[MAXN]; ll ans = INF; long long delivery(int N, int K, int L, int p[]) { n = N; k = K; l = L; for(int i=0; i<n; i++) a[i+1] = p[i]; //cout << n << ' ' << k << ' ' << a[1] << " p\n"; ll nw = 0; for(int i=0; i<=n; i++){ // paling terakhirnya ada di i nw = 0; for(int j=i; j>=1; j-=k){ if(a[j] <= l/2) nw += 2*a[j]; else nw += l; } for(int j=i+1; j<=n; j+=k){ if(a[j] <= l/2) nw += l; else nw += 2*(l-a[j]); } ans = min(ans, nw); } 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...