제출 #1120364

#제출 시각아이디문제언어결과실행 시간메모리
1120364epicci23선물상자 (IOI15_boxes)C++17
10 / 100
1 ms504 KiB
#include "bits/stdc++.h" #include "boxes.h" using namespace std; #define ll long long #define all(x) x.begin() , x.end() #define sz(x) (ll)x.size() const ll INF = 1e18 + 5; ll delivery(int N, int K, int L, int p[]){ ll n = N, k = K , l = L; ll ar[n + 5], pre[n + 5], suf[n + 5]; ar[0] = 0; vector<ll> v; for(ll i = 1 ; i <= n ; i++) v.push_back(p[i-1]); reverse(all(v)); while(!v.empty() && v.back() == 0) v.pop_back(); reverse(all(v)); n = sz(v); if(n == 0) return 0; for(ll i = 1 ; i <= n ; i++) ar[i] = v[i - 1]; pre[0] = suf[n + 1] = 0; for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)]; for(ll i = n ; i >= 1; i--) suf[i] = 2 * ((l - ar[i]) % l) + suf[min(n + 1 , i + k)]; ll ans = INF; for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]); return ans; } /*void _(){ ll n,k,l; cin >> n >> k >> l; ll ar[n + 5], pre[n + 5], suf[n + 5]; for(ll i = 1 ; i <= n ; i++) cin >> ar[i]; pre[0] = suf[n + 1] = 0; for(ll i = 1 ; i <= n ; i++) pre[i] = ar[i] * 2 + pre[max(0LL , i - k)]; for(ll i = n ; i >= 1; i--) suf[i] = 2 * (l - ar[i]) + suf[min(n + 1 , i + k)]; ll ans = INF; for(ll i = 0; i <= n ; i++) ans = min(ans, pre[i] + suf[i+1]); cout << ans << '\n'; } int32_t main(){ ios::sync_with_stdio(0);cin.tie(0); ll tc = 1;//cin >> tc; while(tc--) _(); }*/
#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...