hihoCoder Challenge 8 register

Ended

Participants:280

Verdict:Accepted
Submitted:2015-02-01 20:53:26

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
bool F1[15],F2[15];
int A[15],B[15],i,now,p,n,ans,j,tt,F[15];
char s[10005];
void dfs(int x,int y,int hp,int FF)
{
    if (x==n+1) {if (hp<=0) ans=max(ans,y); return ;}
    dfs(x+1,F2[F[x]]?y+A[F[x]]+A[F[x]]:y+A[F[x]],hp,FF);
    if (hp>0)
    {
        dfs(x+1,y,hp-A[F[x]]*(1-FF),0);
        if (F2[F[x]])
        {
            if (F1[F[x]] || B[F[x]]>8) {dfs(x+1,y,hp-A[F[x]]-A[F[x]]*(1-FF),0); dfs(x+1,y+A[F[x]],hp-A[F[x]]*(1-FF),0);}
        }
    }
}
int main()
{
    while (cin>>n){
    gets(s); ans=0;
    for (i=1; i<=n; i++)
    {
        gets(s); p=strlen(s); F1[i]=F2[i]=false; now=0; tt=0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX