Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

花了两个小时,终于调出来了,看懂样例就花了接近一个小时,伤不起啊

Posted by lmm333 at 2011-07-04 15:30:30 on Problem 3914
int dll[26];
int dllnum[26];
int prog[15];
char proname[15][100];


int main() {
    int a, b, c;
    int l = 0, t1, t2, t3;

    int cnt = 0;

    while (geti(t1), t1) {
        scanf("%d%d", &t2, &t3);
        for (int i = 0; i < t1; ++i) {
            geti(dll[i]);
            dllnum[i] = 0;
        }
        for (int i = 0; i < t2; ++i) {
            geti(prog[i]);
            scanf("%s", proname[i]);
        }

        int max = 0;
        int temp = 0;
        int j;
        for (int i = 0; i < t3; ++i) {
            geti(j);
            if (j > 0) {
                //prog
                temp += prog[j - 1];
                //dll
                for (int k = 0; k < strlen(proname[j - 1]); ++k) {
                    int pos=proname[j-1][k]-'A';
                    dllnum[pos]++;
                    if(dllnum[pos]==1){
                        temp+=dll[pos];
                    }
                }
            }
            else{
                j=-j;
                //prog
                temp -= prog[j - 1];
                //dll
                for (int k = 0; k < strlen(proname[j - 1]); ++k) {
                    int pos=proname[j-1][k]-'A';
                    dllnum[pos]--;
                    if(dllnum[pos]==0){
                        temp-=dll[pos];
                    }
                }
                
            }
            if(temp>max)
                max=temp;
        }
        printf("%d\n",max);

    }


    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator