zoukankan      html  css  js  c++  java
  • Codeforces Round #577 (Div. 2) A

    Codeforces Round #577 (Div. 2)

    A - Important Exam

    A class of students wrote a multiple-choice test.

    There are n students in the class. The test had m questions, each of them had 5 possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question i worth ai points. Incorrect answers are graded with zero points.

    The students remember what answers they gave on the exam, but they don't know what are the correct answers. They are very optimistic, so they want to know what is the maximum possible total score of all students in the class.

    Input

    The first line contains integers n and m (1≤n,m≤1000) — the number of students in the class and the number of questions in the test.

    Each of the next n lines contains string si (|si|=m), describing an answer of the i-th student. The j-th character represents the student answer (A, B, C, D or E) on the j-th question.

    The last line contains m integers a1,a2,…,am (1≤ai≤1000) — the number of points for the correct answer for every question.

    Output

    Print a single integer — the maximum possible total score of the class.

    Examples

    input

    2 4

    ABCD

    ABCE

    1 2 3 4

    output

    16

    input

    3 3

    ABC

    BCD

    CDE

    5 4 12

    output

    21

    Note

    In the first example, one of the most optimal test answers is "ABCD", this way the total number of points will be 16.

    In the second example, one of the most optimal test answers is "CCC", this way each question will be answered by exactly one student and the total number of points is 5+4+12=21.

    题意:题目意思就是有n个学生,m道题目,给出n个学生对m道题目做出的选项 ABCD...和每道题的分数 ,

    然后让你给每道题选择一个答案,使学生的总分最高。

    思路:直接每次看一道题,找出最多的选项加分,

    注意题目给出的分数是每道题的分数,而不是选项的分数。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<algorithm>
     6 #include<map>
     7 #include<set>
     8 #include<vector>
     9 #include<queue>
    10 #include<list>
    11 //#include<unordered_map>
    12 #include<stack>
    13 using namespace std;
    14 #define ll long long 
    15 const int mod=1e9+7;
    16 const int inf=1e9+7;
    17  
    18 const int maxn=1e3+10;
    19  
    20 string str[maxn];
    21  
    22 int point[maxn];
    23  
    24 int main()
    25 {
    26     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    27     
    28     int n,m;
    29     
    30     cin>>n>>m;
    31     
    32     for(int i=0;i<n;i++)
    33         cin>>str[i];
    34     
    35     for(int i=0;i<m;i++)
    36         cin>>point[i];
    37     
    38     map<char,int>book;
    39     
    40     ll int sum=0;
    41     for(int i=0;i<m;i++)
    42     {
    43         book.clear();
    44         ll int maxx=-1;
    45         for(int j=0;j<n;j++)
    46         {
    47             book[str[j][i]]++;
    48             
    49             if(book[str[j][i]]>maxx)
    50             {
    51                 maxx=book[str[j][i]];
    52             }
    53         }
    54         sum+=point[i]*maxx;
    55     
    56     }
    57     
    58     cout<<sum<<endl;
    59     
    60     return 0;
    61 }
    大佬见笑,,
  • 相关阅读:
    flex 弹性盒布局 移动端首页
    less+rem基础使用
    github 本地操作
    git 码云
    react基础知识
    css样式
    uni-app 知识点
    web app
    2019年一半已过,这些大前端技术你都GET了吗?- 下篇
    2019年大前端技术周刊-#31周
  • 原文地址:https://www.cnblogs.com/xwl3109377858/p/11305730.html
Copyright © 2011-2022 走看看