ACM Contest Scoring(UVALive 7350)

Description

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 file contains several test cases, each of them as described below.
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 ‘-1’.

Output

For each case, output two integers on a single line: the number of problems solved and the total time
measure (including penalties).

Sample Input

3 E right
10 A wrong
30 C wrong
50 B wrong
100 A wrong
200 A right
250 C wrong
300 D right
-1
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
-1

Sample Output

3 543
4 502

题解:

之前写过类似题,不过做到了就再来一边吧,很简单,模拟oj算罚时。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
#define swap(a,b)  (a=a+b,b=a-b,a=a-b)
#define maxn 320007
#define N 100000000
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define Debug(x) cout<<x<<" "<<endl
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
#define fori(n) for(int i=0;i<n;i++)
//std::ios::sync_with_stdio(false);
//cin.tie(NULL);
using namespace std;

struct qaq
{
    int x;
    char c;
    char b[6];
}a[111];
int p[27];
int q[27];
int main()
{
    int i=0,sum=0,s=0;
    while(cin>>a[i].x)
    {
        if(a[i].x==-1)
        {
            cout<<s<<" "<<sum<<endl;
            i=0;
            sum=0;
            s=0;
            memset(a,0);
            memset(p,0);
            memset(q,0);
            continue;
        }
        cin>>a[i].c>>a[i].b;
        if(p[a[i].c-'A']==0&&a[i].b[0]=='r')
        {
            p[a[i].c-'A']++;
            sum+=a[i].x+q[a[i].c-'A'];
            s++;
        }
        else if(p[a[i].c-'A']==1)
            continue;
        else if(p[a[i].c-'A']==0)
            q[a[i].c-'A']+=20;
        i++;
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值