제출 #110025

#제출 시각아이디문제언어결과실행 시간메모리
110025CaroLinda선물상자 (IOI15_boxes)C++14
10 / 100
3 ms384 KiB
#include <bits/stdc++.h> #define lp(i,a,b) for(int i = a ; i < b ; i++) #define ll long long #define ff first #define ss second const int MAXN = 1e7 + 5; const int inf = 1e9 + 10 ; using namespace std ; //Declaracoes int N , K , L ; int pos[MAXN] ; ll dp1[MAXN] , dp2[MAXN] ; void print() { lp(i,0,N) cout<<dp1[i]<<" "; cout<<endl ; lp(i,0,N) cout<<dp2[i]<<" "; cout<<endl; } //Funcao principal ll delivery(int n , int k , int l , int positions[] ) { //Globalizacao N = n ; K = k ; L = l ; lp(i,0,n) pos[i] = positions[i] ; lp(i,0,n) if( pos[i] == 0 ) pos[i] = inf , N-- ; sort( pos , pos + n ) ; n = N ; lp(i,0,n) { dp1[i] = pos[i] * 2LL ; if( i - k >= 0 ) dp1[i] += dp1[i-k] ; } for( int i = n-1 ; i >= 0 ; i-- ) { dp2[i] = ( L - pos[i]) * 2LL ; if( i + k < n ) dp2[i] += dp2[i+k] ; } ll best = 1LL * inf * MAXN ; lp(i,0,n) best = min( best , dp1[i] + dp2[i+1] ) ; lp(i,0,n) { ll x = 0; if( i + k < n ) x = dp2[i+k] ; ll y = 0 ; if( i-1 >= 0 ) y = dp1[i-1] ; best = min( best , y + x + L ) ; } return best ; }
#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...