제출 #1272105

#제출 시각아이디문제언어결과실행 시간메모리
1272105thunopro선물상자 (IOI15_boxes)C++20
0 / 100
1 ms576 KiB
#include "boxes.h" #include<bits/stdc++.h> using namespace std ; #define maxn 200009 #define ll long long #define pb push_back #define fi first #define se second #define left id<<1 #define right id<<1|1 #define re exit(0); #define _lower(x) lower_bound(v.begin(),v.end(),x)-v.begin()+1 #define TIME ( 1.0*clock() / CLOCKS_PER_SEC ) const int mod = 1e9+7 ; const int INF = 1e9 ; typedef vector<int> vi ; typedef pair<int,int> pii ; typedef vector<pii> vii ; template < typename T > void chkmin ( T &a , T b ) { if ( a > b ) a = b ; } template < typename T > void chkmax ( T &a , T b ) { if ( a < b ) a = b ; } void add ( int &a , int b ) { a += b ; if ( a >= mod ) a -= mod ; if ( a < 0 ) a += mod ; } int n , k , L ; int p [maxn] ; ll dp [maxn] ; bool in_right ( int pos ) { return ( pos >= (L+1)/2 ) ; } long long delivery(int _N, int _K, int _L, int _p[]) { n = _N , k = _K , L = _L ; for ( int i = 1 ; i <= n ; i ++ ) p [i] = _p [i-1] ; int pos = -1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( in_right (p[i]) ) { pos = i ; break ; } dp [i] = dp [max(0,i-k)] + p [i] ; } for ( int i = n ; in_right (p[i]) ; i -- ) dp [i] = dp [min(n+1,i+k)] + L - p [i] ; ll res = 1e18 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i + k - 1 < pos ) continue ; if ( i + k - 1 > n || i >= pos ) break ; res = min (res,2*dp[i-1]+2*dp[i+k]+L) ; } if ( pos != - 1 ) res = min (res,dp[pos-1]*2+dp[pos]*2) ; return res; }
#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...