Submission #124184

# Submission time Handle Problem Language Result Execution time Memory
124184 2019-07-02T15:27:01 Z mechfrog88 Safety (NOI18_safety) C++11
0 / 100
25 ms 2680 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;	


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
		int n,a;
		cin >> n >> a;
		if (n <= 14) return 0;
		vector <ll> arr(n+1,0);
		ll maxi = 0;
		for (int z=1;z<=n;z++){
			cin >> arr[z];
			maxi = max(maxi,arr[z]);
		}
		vector <vector<ll>> dp(n+1,vector<ll>(maxi+1,0));
		for (ll z=1;z<=n;z++){
			for (ll h=0;h<=maxi;h++){
				ll mini = LLONG_MAX;
				for (ll x=max(ll(0),h-a);x<=min(maxi,h+a);x++){
					mini = min(mini,dp[z-1][x]);
				}
				dp[z][h] = mini+abs(arr[z]-h);
			}
		}
		ll mini = LLONG_MAX;
		for(ll z=0;z<=maxi;z++){
	
				mini = min(dp[n][z],mini);
			}
		cout << mini << endl;

}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 2680 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -