제출 #532030

#제출 시각아이디문제언어결과실행 시간메모리
532030nguyentunglam선물상자 (IOI15_boxes)C++14
0 / 100
1 ms304 KiB
#include<bits/stdc++.h>
#define forin(i, a, b) for(int i = a; i <= b; i++)
#define forde(i, a, b) for(int i = a; i >= b; i--)
#define fi first 
#define se second
#define ll long long
using namespace std;
const int N = 1e7 + 10;
int a[N], dp[2][N];
int res = 1e9;
int delivery(int n, int k, int l,int a[])
{
	//forin(i, 1, n) cin >> a[i];
	forin(i, 1, n) dp[0][i] = dp[0][max(0, i-k)] + a[i] + min(a[i], l-a[i]);
	forde(i, n, 1) dp[1][i] = dp[1][min(n+1, i+k)] + l-a[i] + min(a[i], l - a[i]);
	forin(i, 1, n+1) res = min(res, dp[0][i-1] + dp[1][i]);
	//forde(i, n, 1) cout << dp[1][i]<<" ";
	return res;
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'int delivery(int, int, int, int*)':
boxes.cpp:11:38: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   11 | int delivery(int n, int k, int l,int a[])
      |                                  ~~~~^~~
boxes.cpp:9:5: note: shadowed declaration is here
    9 | int a[N], dp[2][N];
      |     ^
#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...