제출 #496193

#제출 시각아이디문제언어결과실행 시간메모리
496193kevin선물상자 (IOI15_boxes)C++17
70 / 100
1037 ms524292 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define nl cout<<"\n" #define ca(v) for(auto i:v) cout<<i<<" "; ll delivery(int N, int K, int L, int* ar){ sort(ar, ar+N); vector<vector<ll>> cost(N, vector<ll>(2, 0)); vector<ll> cost0(N, 0); vector<ll> cost1(N, 0); for(int i=0; i<N; i++){ if(i<K) { cost0[i] = (ll)ar[i] + min(ar[i], L - ar[i]); cost1[N-1-i] = (ll)(L - ar[N-1-i]) + min(ar[N-1-i], L - ar[N-1-i]); } else { cost0[i] = (ll)ar[i] + min(ar[i], L - ar[i]) + cost0[i-K]; cost1[N-1-i] = (ll)(L - ar[N-1-i]) + min(ar[N-1-i], L - ar[N-1-i]) + cost1[N-1-i+K]; } } ll ans = cost1[0]; ans = min(ans, cost0[N-1]); for(int i=0; i<N-1; i++){ ans = min(ans, cost0[i] + cost1[i+1]); } return ans; } // int main() // { // ios_base::sync_with_stdio(0); cin.tie(0); // if (fopen("input.in", "r")) freopen("input.in", "r", stdin); // int N, K, L; // cin>>N>>K>>L; // vector<int> ar(N); // for(int i=0; i<N; i++) cin>>ar[i]; // cout<<delivery(N, K, L, ar); // }
#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...