AT_abc467_b.Keep the Change

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Takahashi made purchases at NN stores. Initially, he had 1000010000 yen.
At the ii-th store, he bought an item worth AiA_i yen and paid BiB_i yen. Here, Ai≤BiA_i \leq B_i holds. If Si=S_i = keep, he did not receive the change, and if Si=S_i = take, he received the change.
Find the amount of money he lost compared to the case where he received the change at every store. To be precise,

  • let XX yen be Takahashi's final amount of money, and
  • let YY yen be Takahashi's final amount of money in the case where he received the change at every store.

Find Y−XY - X.

高桥在 NN 家商店进行了购物。最初,他有 1000010000 日元。
在第 ii 家商店,他购买了一件价值 AiA_i 日元的商品,并支付了 BiB_i 日元。其中满足 Ai≤BiA_i \leq B_i。若 Si=S_i = keep,则他未领取找零;若 Si=S_i = take,则他领取了找零。
求他相较于“在每家商店都领取找零”的情形所损失的金额。具体而言:

  • 设 XX 日元为高桥最终剩余的钱数;
  • 设 YY 日元为高桥在“每家商店都领取找零”的情形下最终剩余的钱数。

请计算 Y−XY - X。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 B1B_1 S1S_1
A2A_2 B2B_2 S2S_2
⋮\vdots
ANA_N BNB_N SNS_N

输入从标准输入给出,格式如下:

NN
A1A_1 B1B_1 S1S_1
A2A_2 B2B_2 S2S_2
⋮\vdots
ANA_N BNB_N SNS_N

输出格式

Output the amount of money Takahashi lost compared to the case where he received the change at every store.

输出高桥君相较于在每家商店都找零的情况下所损失的金额。

输入输出样例

  • 输入#1

    3
    1 2 keep
    3 6 take
    5 9 keep

    输出#1

    5
  • 输入#2

    8
    36 49 take
    38 73 keep
    27 85 take
    65 71 take
    52 86 keep
    48 60 keep
    37 98 keep
    5 38 keep

    输出#2

    175

说明/提示

Sample 1 Explanation:
Takahashi's actions are as follows.

  • At the first store, he bought an item worth 11 yen, paid 22 yen, and did not receive the change.
  • At the second store, he bought an item worth 33 yen, paid 66 yen, and received the change.
  • At the third store, he bought an item worth 55 yen, paid 99 yen, and did not receive the change.

Constraints

  • 1≤N≤1001 \leq N \leq 100
  • 1≤Ai≤Bi≤1001 \leq A_i \leq B_i \leq 100
  • SiS_i is keep or take.
  • N,Ai,BiN, A_i, B_i are all integers.

样例 1 解释:
高桥的行为如下:

  • 在第一家商店,他购买了一件价值 11 日元的商品,支付了 22 日元,且未领取找零。
  • 在第二家商店,他购买了一件价值 33 日元的商品,支付了 66 日元,且领取了找零。
  • 在第三家商店,他购买了一件价值 55 日元的商品,支付了 99 日元,且未领取找零。

限制条件

  • 1≤N≤1001 \leq N \leq 100
  • 1≤Ai≤Bi≤1001 \leq A_i \leq B_i \leq 100
  • SiS_i 为 keep 或 take。
  • N,Ai,BiN, A_i, B_i 均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页