牛牛的签到奖励
牛牛的签到奖励
https://ac.nowcoder.com/acm/contest/9799/A
//暴力枚举
#include<bits/stdc++.h>
using namespace std;
int a,b;
int h[10];//对应星期几的奖励
int month[]={31,31,28,31,30,31,30,31,31,30,31,30,31};//平年当中每个月份的天数
int vis[35];//记录哪一天签到了
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(int i=1;i<=7;i++)
cin>>h[i];
h[0]=h[7];
int deadline=month[b]+(b==2&&((a%400==0)||(a%4==0&&a%100!=0)));//闰年二月天数+1
for(int i=1;i<=deadline;i++)
cin>>vis[i];
int ans=0x3f3f3f3f;
//枚举一号是星期几
for(int i=1;i<=7;i++)
{
int day=i,sum=0;//sum记录获得的奖励
for(int j=1;j<=deadline;j++)
{
day%=7;
if(vis[j]==1)
{
sum+=h[day];
}
day++;
}
ans=min(ans,sum);//更新最小值
}
cout<<ans<<endl;
return 0;
}