제출 #308185

#제출 시각아이디문제언어결과실행 시간메모리
308185talant117408선물상자 (IOI15_boxes)C++17
100 / 100
601 ms274808 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <ll, ll> pii; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) (v).size() #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); const int N = 1e7+7; vector <ll> needl(N), needr(N), v(N); int n, k, cir; ll delivery(int NN, int KK, int LL, int p[]){ int i; n = NN; k = KK; cir = LL; for(i = 0; i < n; i++){ v[i+1] = p[i]; } for(i = 1; i <= n; i++){ needl[i] = needl[max(0, i-k)]+v[i]*2; } for(i = n; i >= 1; i--){ needr[i] = needr[min(n+1, i+k)]+(cir-v[i])*2; } ll mn = 9e18; for(i = 0; i <= n; i++){ mn = min(mn, needl[i]+needr[i+1]); } for(i = 0; i <= n; i++){ mn = min(mn, needl[i]+cir+needr[min(n+1, i+k+1)]); } return mn; }
#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...