제출 #434387

#제출 시각아이디문제언어결과실행 시간메모리
434387bipartite_matching선물상자 (IOI15_boxes)C++14
100 / 100
663 ms284412 KiB
#include <bits/stdc++.h> #define forint(i, N) for (int i = 0; i < (N); i++) using namespace std; typedef long long ll; ll delivery(int n, int k, int l, int p[]) { vector<int> dist(n); for (int i = 0; i < n; i++) { dist[i] = min(p[i], l - p[i]); } vector<ll> costl(n); vector<ll> costr(n); costl[0] = 2 * dist[0]; for (int i = 1; i < n; i++) { costl[i] = i >= k ? (ll)(costl[i - k] + p[i] + dist[i]) : (ll)(p[i] + dist[i]); } costr[n - 1] = 2 * dist[n - 1]; for (int i = n - 2; i >= 0; i--) { costr[i] = i + k < n ? (ll)(costr[i + k] + l - p[i] + dist[i]) : (ll)(l - p[i] + dist[i]); } ll ret = min(costl[n - 1], costr[0]); forint(i, n - 1) { if (costl[i] + costr[i + 1] < ret) ret = costl[i] + costr[i + 1]; } /*forint(i, n) { cerr << costl[i] << " - " << costr[i] << endl; }*/ return ret; }
#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...