Submission #85884

# Submission time Handle Problem Language Result Execution time Memory
85884 2018-11-22T13:19:00 Z farukkastamonuda Skyline (IZhO11_skyline) C++14
100 / 100
191 ms 55844 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 305
#define mid (start+end)/2
using namespace std;
int n,A[li],dp[li][205][205];
int dfs(int node,int h1,int h2){
	int cev=inf;
	if(node==n+1) return 0;
	if(~dp[node][h1][h2]) return dp[node][h1][h2];
	if(h1){
		cev=min(cev,dfs(node,h1-1,h2)+3);
		if(h2){
			cev=min(cev,dfs(node,h1-1,h2-1)+5);
			if(h1<=min(h2,A[node+2])){
				cev=min(cev,dfs(node+1,h2-h1,A[node+2]-h1)+7*h1);
			}
		}
	}
	else cev=min(cev,dfs(node+1,h2,A[node+2]));
	return dp[node][h1][h2]=cev;
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	int ty=dfs(1,A[1],A[2]);
	printf("%d\n",ty);
	return 0;
}

Compilation message

skyline.cpp: In function 'int main()':
skyline.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
skyline.cpp:32:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&A[i]);
                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 46 ms 50680 KB Output is correct
2 Correct 42 ms 50760 KB Output is correct
3 Correct 42 ms 50760 KB Output is correct
4 Correct 43 ms 50868 KB Output is correct
5 Correct 42 ms 50868 KB Output is correct
6 Correct 43 ms 50892 KB Output is correct
7 Correct 44 ms 50912 KB Output is correct
8 Correct 43 ms 50956 KB Output is correct
9 Correct 44 ms 51340 KB Output is correct
10 Correct 50 ms 51340 KB Output is correct
11 Correct 61 ms 52048 KB Output is correct
12 Correct 47 ms 52048 KB Output is correct
13 Correct 59 ms 52372 KB Output is correct
14 Correct 71 ms 52760 KB Output is correct
15 Correct 140 ms 54812 KB Output is correct
16 Correct 135 ms 54812 KB Output is correct
17 Correct 185 ms 55844 KB Output is correct
18 Correct 180 ms 55844 KB Output is correct
19 Correct 168 ms 55844 KB Output is correct
20 Correct 191 ms 55844 KB Output is correct