제출 #1034697

#제출 시각아이디문제언어결과실행 시간메모리
1034697Zicrus선물상자 (IOI15_boxes)C++17
20 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "boxes.h" using namespace std; typedef long long ll; ll left(int n, int k, int l, vector<ll> p) { ll sum = 0; ll pos = 0; for (int i = 0; i < n; i++) { sum += min(abs(p[i]-pos), l-abs(p[i]-pos)); pos = p[i]; if ((i+1) % k == 0) { sum += min(pos, l-pos); pos = 0; } } return sum + min(pos, l-pos); } ll right(int n, int k, int l, vector<ll> p) { reverse(p.begin(), p.end()); ll sum = 0; ll pos = 0; for (int i = 0; i < n; i++) { sum += min(abs(p[i]-pos), l-abs(p[i]-pos)); pos = p[i]; if ((i+1) % k == 0) { sum += min(pos, l-pos); pos = 0; } } return sum + min(pos, l-pos); } ll delivery(int n, int k, int l, int p11[]) { vector<ll> p(n); for (int i = 0; i < n; i++) p[i] = p11[i]; return min(left(n, k, l, p), right(n, k, l, p)); }
#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...