제출 #1289328

#제출 시각아이디문제언어결과실행 시간메모리
1289328blackscreen1선물상자 (IOI15_boxes)C++20
100 / 100
353 ms196164 KiB
#include "boxes.h" #include <bits//stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define ll long long #define ld long double #define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1)) #define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1)) #define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1)) #define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1)) #define iloop_(m, h, g) for (auto i = m; i < h; i += g) #define jloop_(m, h, g) for (auto j = m; j < h; j += g) #define kloop_(m, h, g) for (auto k = m; k < h; k += g) #define lloop_(m, h, g) for (auto l = m; l < h; l += g) #define getchar_unlocked _getchar_nolock // comment before submission #define pll pair<ll, ll> #define plll pair<ll, pll> #define pllll pair<pll, pll> #define vll vector<ll> #define qll queue<ll> #define dll deque<ll> #define pqll priority_queue<ll> #define gll greater<ll> #define INF 1000000000000000 #define MOD1 1000000007 #define MOD2 998244353 #define MOD3 1000000009 mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); ll n, k, l; long long delivery(int N, int K, int L, int p[]) { n = N, k = K, l = L; ll b1[n], b2[n]; iloop(0, n) b1[i] = p[i] + (i >= k ? b1[i-k] + p[i-k] : 0); iloop(n-1, -1) b2[i] = l-p[i] + (i < n-k ? b2[i+k] + l-p[i+k] : 0); ll cans = INF; iloop(0, n-1) cans = min(cans, b1[i] + b2[i+1] + min((ll)p[i], l-p[i]) + min((ll)p[i+1], l-p[i+1])); cans = min(cans, b2[0] + min((ll)p[0], l-p[0])); cans = min(cans, b1[n-1] + min((ll)p[n-1], l-p[n-1])); return cans; }
#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...