제출 #1272075

#제출 시각아이디문제언어결과실행 시간메모리
1272075crispxx선물상자 (IOI15_boxes)C++20
100 / 100
352 ms196104 KiB
#include <bits/stdc++.h> #include "boxes.h" // #include "grader.cpp" using namespace std; // #define int long long #define all(x) x.begin(), x.end() #define pb push_back #define ar array #define nl '\n' template <typename A, typename B> bool chmin(A &a, const B &b) { if(a > b) { return a = b, true; } return false; } template <typename A, typename B> bool chmax(A &a, const B &b) { if(a < b) { return a = b, true; } return false; } long long delivery(int n, int k, int l, int p[]) { vector<long long> pref(n + 1), suf(n + 1); for(int i = 0; i < n; i++) { pref[i + 1] = pref[ max(0, i - k + 1) ] + 2 * p[i]; } for(int i = n - 1; i >= 0; i--) { suf[i] = suf[ min(n, i + k) ] + 2 * (l - p[i]); } long long ans = pref[n]; for(int i = 0; i + k <= n; i++) { chmin(ans, pref[i] + suf[i + k] + l); } for(int i = 0; i < n; i++) { chmin(ans, pref[i] + suf[i]); } 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...