답안 #124176

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124176 2019-07-02T15:21:49 Z mechfrog88 Safety (NOI18_safety) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	if (n <= 14){
		ll n,d;
		cin >> n >> d;
		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-d);x<=min(maxi,h+d);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;
	} else {
		cout << 1 << endl;
	}

}

Compilation message

safety.cpp: In function 'int main()':
safety.cpp:20:6: error: 'n' was not declared in this scope
  if (n <= 14){
      ^
safety.cpp:20:6: note: suggested alternative: 'yn'
  if (n <= 14){
      ^
      yn
safety.cpp:21:6: error: redeclaration of 'll n'
   ll n,d;
      ^
safety.cpp:20:6: note: '<typeprefixerror>n' previously declared here
  if (n <= 14){
      ^