codeforces 681A A Good Contest

本文介绍了一个简单程序,用于分析Codeforces用户在比赛中是否超越了红名选手且该选手赛后评级提升,以此判断参赛者的表现是否良好。

点击打开链接

A. A Good Contest
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Codeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it is orange if his rating is less than 2400 but greater or equal to 2200, etc. Each time participant takes part in a rated contest, his rating is changed depending on his performance.

Anton wants the color of his handle to become red. He considers his performance in the rated contest to be good if he outscored some participant, whose handle was colored red before the contest and his rating has increased after it.

Anton has written a program that analyses contest results and determines whether he performed good or not. Are you able to do the same?

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of participants Anton has outscored in this contest .

The next n lines describe participants results: the i-th of them consists of a participant handle namei and two integers beforei and afteri( - 4000 ≤ beforei, afteri ≤ 4000) — participant's rating before and after the contest, respectively. Each handle is a non-empty string, consisting of no more than 10 characters, which might be lowercase and uppercase English letters, digits, characters «_» and «-» characters.

It is guaranteed that all handles are distinct.

Output

Print «YES» (quotes for clarity), if Anton has performed good in the contest and «NO» (quotes for clarity) otherwise.

Examples
input
3
Burunduk1 2526 2537
BudAlNik 2084 2214
subscriber 2833 2749
output
YES
input
3
Applejack 2400 2400
Fluttershy 2390 2431
Pinkie_Pie -2500 -2450
output
NO
Note

In the first sample, Anton has outscored user with handle Burunduk1, whose handle was colored red before the contest and his rating has increased after the contest.

In the second sample, Applejack's rating has not increased after the contest, while both Fluttershy's and Pinkie_Pie's handles were not colored red before the contest.


题意看不懂,随便写的,一次竟然过了,百度翻译,谷歌翻译什么的也看不懂,有明白什么题意的,评论一下。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    char s[15];
    int a,b;
    cin>>n;
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        cin>>s>>a>>b;
        if(a>=2400&&b>=2400&&a<b)
            flag=true;
    }
    if(flag)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


### Codeforces Contest 370 Problem A: "Ksenia and Pan Scales" 在Codeforces竞赛370中的问题A,题目名为“Ksenia and Pan Scales”,要求解决一个关于天平的问题。具体来说,问题是围绕天平的平衡条件展开的,需要判断给定的一组重量是否能够使天平保持平衡[^1]。 #### 问题描述 给定一个字符串 `s` 表示天平的状态,其中包含字符 `'.'` 和 `'*'`。字符 `'.'` 表示空位,而字符 `'*'` 表示放置了砝码的位置。任务是检查是否存在一种方法,通过将砝码分配到天平的两侧,使得天平达到平衡状态。 #### 解决方案 解决方案的核心思想是模拟天平的工作原理,并计算左右两边的力矩差值。以下是具体的实现步骤: 1. 首先,遍历字符串 `s`,统计左侧和右侧的力矩。 2. 如果左右力矩相等,则输出 `"YES"`,否则输出 `"NO"`。 以下是实现该算法的代码示例: ```python def solve_pan_scales(s): left_torque = 0 right_torque = 0 n = len(s) for i in range(n): if s[i] == '*': if i < n // 2: left_torque += (n // 2 - i) elif i > n // 2: right_torque += (i - n // 2) if left_torque == right_torque: return "YES" else: return "NO" # 示例输入 s = input().strip() print(solve_pan_scales(s)) ``` 此代码通过计算天平两侧的力矩来判断是否可以达到平衡状态[^2]。 #### 注意事项 - 输入字符串的长度为奇数,确保天平中心点明确。 - 确保正确处理边界情况,例如所有砝码都在一侧的情况。 ### 结论 通过上述方法,可以有效地解决 Codeforces Contest 370 Problem A 的问题。该方法的时间复杂度为 O(n),满足题目对时间限制的要求[^3]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值