提交时间:2023-11-25 09:37:16
运行 ID: 111987
#include<bits/stdc++.h> using namespace std; int step[1001],n,cost,minn=99999999; void stair(int s1,int s2,int c) { if(s1>=n||s2>=n) {if(minn>c){minn=c;}return;} c+=step[s1]; stair(s1+1,s1+2,c); c-=step[s1]; c+=step[s2]; stair(s2+1,s2+2,c); c-=step[s2]; } int main() { cin>>n; for(int i=0;i<n;i++) {cin>>step[i];} stair(0,1,0); cout<<minn; }