Summer Training Team Selection (1) Problem A ACM Contest Scoring 水题

快半个月没有把自己的代码什么更新上来了,这两周既是期中考试又是数据结构专题training,然后今晚专题结束才能把早就放在草稿箱的那些放出来☺

今天下午一次队内赛,做的中东的区域赛的。感觉自己太智障了,第一题还CE了一次time标识符在BC上都好用的,但OJ说不行,以后用_time或者什么好了,

然后输出格式没有注意就交了一发,……


Problem A
ACM Contest Scoring
Time limit: 1 second
Our new contest submission system keeps a chronological log of all submissions made by each team during
the contest. With each entry, it records the number of minutes into the competition at which the submission
was received, the letter that identifies the relevant contest problem, and the result of testing the submission
(designated for the sake of this problem simply as right or wrong). As an example, the following is a
hypothetical log for a particular team:
3 E right
10 A wrong
30 C wrong
50 B wrong
100 A wrong
200 A right
250 C wrong
300 D right
The rank of a team relative to others is determined by a primary and secondary scoring measure calculated
from the submission data. The primary measure is the number of problems that were solved. The secondary
measure is based on a combination of time and penalties. Specifically, a team’s time score is equal to the
sum of those submission times that resulted in right answers, plus a 20-minute penalty for each wrong
submission of a problem that is ultimately solved. If no problems are solved, the time measure is 0.


In the above example, we see that this team successfully completed three problems: E on their first attempt
(3 minutes into the contest); A on their third attempt at that problem (200 minutes into the contest); and
D on their first attempt at that problem (300 minutes into the contest). This team’s time score (including
penalties) is 543. This is computed to include 3 minutes for solving E, 200 minutes for solving A with an
additional 40 penalty minutes for two earlier mistakes on that problem, and finally 300 minutes for solving

D. Note that the team also attempted problems B and C, but were never successful in solving those problems,
and thus received no penalties for those attempts.
According to contest rules, after a team solves a particular problem, any further submissions of the same
problem are ignored (and thus omitted from the log). Because times are discretized to whole minutes, there
may be more than one submission showing the same number of minutes. In particular there could be more
than one submission of the same problem in the same minute, but they are chronological, so only the last
entry could possibly be correct. As a second example, consider the following submission log:
7 H right
15 B wrong
30 E wrong
35 E right
80 B wrong
80 B right
100 D wrong
100 C wrong
300 C right
300 D wrong
This team solved 4 problems, and their total time score (including penalties) is 502, with 7 minutes for H,
35 + 20 for E, 80 + 40 for B, and 300 + 20 for C.

Input
The input contains n lines for 0  n  100, with each line describing a particular log entry. A log entry has
three parts: an integer m, with 1  m  300, designating the number of minutes at which a submission was
received, an uppercase letter designating the problem, and either the word right or wrong. The integers
will be in nondecreasing order and may contain repeats. After all the log entries is a line containing just the
number

题目给的是pdf版的^_^

Source

2016 UESTC ACM Summer Training Team Selection (1)

ACM-ICPC 2015 Mid-Central Regional Problem A: ACM Contest Scoring

My Solution

水题,模拟ACM赛制算总罚时

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

int _time[26];
char rorw[6];
map<int, int> _right;

int main()
{
    #ifdef LOCAL
    freopen("a.txt", "r", stdin);
    #endif // LOCAL
    int m, pr, ans = 0, num = 0;
    char problem;
    memset(_time, 0, sizeof _time);
    while(scanf("%d", &m)){
        if(m == -1) break;
        getchar();
        scanf("%c", &problem);
        scanf("%s", rorw);
        pr = problem-'A';
        if(rorw[0] == 'w'){
            if(_right[pr] == 0){
                _time[pr] += 20;
            }
        }
        else{
            if(_right[pr] == 0){
                _time[pr] += m;
                _right[pr]++;
            }
        }
    }
    for(int i = 0; i < 26; i++){
        if(_right[i] != 0){
            ans += _time[i];
            num++;
        }
    }
    printf("%d %d", num, ans);
    return 0;
}

Thank you!



你可能感兴趣的:(模拟,ACM,水题)