답안 #930415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930415 2024-02-19T15:00:51 Z Cutebol 선물상자 (IOI15_boxes) C++17
0 / 100
1 ms 2396 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e7 + 4 ;

template <class T>
bool chmax( T& x , const T& y ){
  bool f = 0 ;
  if ( x < y ) x = y , f = 1 ;
  return f ;
}
template <class T>
bool chmin( T &x , const T &y ){
  bool f = 0 ;
  if ( x > y ) x = y , f = 1 ;
  return f ;
}

int dpl[N] , dpr[N] ;

long long delivery(int n, int k, int l, int a[]) {
	
	for ( int i = 0 ; i < n ; i ++ ){
		if ( i + 1 >= k ) dpl[i] = dpl[i-k] + 2*a[i] ;
		else dpl[i] = 2*a[i] ;
	}
	for ( int i = n-1 ; i >= 0 ; i -- ){
		if ( n-i >= k ) dpr[i] = dpl[i+k] + 2*(l-a[i]) ;
		else dpr[i] = 2*(l-a[i]) ;
	}
	int ans = min ( dpl[n-1] , dpr[0] ) ;
	for ( int i = 1 ; i < n ; i ++ ){
		chmin ( ans , dpl[i-1]+dpr[i] ) ;
	}
	return ans ;
}

/*
int a[N] ;
signed main(){
	int n , k , l ; cin >> n >> k >> l ;
	for ( int i = 0 ; i < n ; i ++ ) cin >> a[i] ;
	
	cout << delivery( n , k , l , a ) ;
}
//*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -