제출 #320365

#제출 시각아이디문제언어결과실행 시간메모리
320365nikatamliani선물상자 (IOI15_boxes)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; long long delivery(int N, int K, int L, int positions[]) { long long p[N], s[N]; for(int i = 0; i < N; ++i) { p[i] = positions[i]; if(i >= K) { p[i] += p[i - K]; } p[i] *= 2; } for(int i = N - 1; i >= 0; --i) { s[i] = L - positions[i]; if(i + K < N) { s[i] += s[i + K]; } s[i] *= 2; } long long answer = p[N - 1]; for(int i = 0; i < N - 1; ++i) { answer = min(answer, p[i] + s[i + 1]); } for(int start = 0; start + K - 1 < N; ++start) { int end = start + K - 1; long long left = (start > 0 ? p[start - 1] : 0); long long right = (end < N - 1 ? s[end + 1] : 0); long long middle = L; answer = min(answer, left + middle + right); } return answer; } // int main() { // int pos[] = {1, 2, 5}; // cout << delivery(3, 2, 8, pos) << '\n'; // }
#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...