您的位置:首页 > 运维架构

C - Shopping Street(AtCoder Beginner Contest 080)

2017-12-03 22:29 447 查看

题目链接

             https://beta.atcoder.jp/contests/abc080/tasks/abc080_c

解题方法

          因为一共只有十个时期所以我们可以枚举所有的状态,又因为必须有1个时期开放,所以我们从1而不是0开始枚举

AC代码

#include<stdio.h>
#include<string.h>
#include <iostream>
#include<algorithm>
using namespace std;

typedef long long LL;

const int INF = 0x3f3f3f3f;
const int maxn = 100 + 10;
LL F[maxn][maxn];
LL P[maxn][maxn];
LL D[maxn];

int main()
{
LL n;
while(scanf("%lld",&n) == 1)
{
for(int i = 1; i <= n; i++)
for(int j = 1; j <= 10; j++)
scanf("%lld",&F[i][j]);

for(int i = 1; i <= n; i++)
for(int j = 0; j <= 10; j++)
scanf("%lld",&P[i][j]);

LL Max = -1 * INF;
for(int s = 1; s < (1 << 10); s++)
{
for(int i = 1; i <= n; i++)
{
D[i] = 0;
for(int j = 1; j <= 10; j++)
{
if((F[i][j] << (j - 1)) & s) D[i]++;
}
}

LL ans = 0;
for(int i = 1; i <= n; i++)
ans += P[i][D[i]];

Max = max(Max,ans);
}
cout<< Max <<endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: