Submission #36306

#TimeUsernameProblemLanguageResultExecution timeMemory
36306KerimSkyline (IZhO11_skyline)C++14
100 / 100
393 ms54884 KiB
#pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("avx") #include "bits/stdc++.h" #define MAXN 100009 #define INF 1000000007 #define mp(x,y) make_pair(x,y) #define all(v) v.begin(),v.end() #define pb(x) push_back(x) #define wr cout<<"----------------"<<endl; #define ppb() pop_back() #define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++) #define ff first #define ss second #define my_little_dodge 46 #define debug(x) cerr<< #x <<" = "<< x<<endl; using namespace std; typedef long long ll; typedef pair<int,int> PII; template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int K=202; const int N=303; int dp[K][K][N],n,arr[N]; int rec(int x,int y,int pos){ if(pos==n) return x*3; int &ret=dp[x][y][pos]; if(~ret) return ret;ret=INF; if(pos+2<=n){ if(x){ umin(ret,rec(x-1,y,pos)+3); if(y) umin(ret,rec(x-1,y-1,pos)+5); } if(y>=x and arr[pos+2]>=x) umin(ret,rec(y-x,arr[pos+2]-x,pos+1)+x*7); } else{ if(!x) ret=rec(y,0,n); else{ umin(ret,rec(x-1,y,pos)+3); if(y) umin(ret,rec(x-1,y-1,pos)+5); } } return ret; } int main(){ //~ freopen("file.in", "r", stdin); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",arr+i); if(n==1){ printf("%d\n",arr[1]*3); return 0; } if(n==2){ printf("%d\n",min(arr[1],arr[2])*5+(max(arr[1],arr[2])-min(arr[1],arr[2]))*3); return 0; } memset(dp,-1,sizeof dp); printf("%d\n",rec(arr[1],arr[2],1)); return 0; }

Compilation message (stderr)

skyline.cpp: In function 'int main()':
skyline.cpp:53:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
skyline.cpp:55:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",arr+i);
                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...