codeforce 6C

http://codeforces.com/problemset/problem/6/C

Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice and Bob eat them with equal speed). When the player consumes a chocolate bar, he immediately starts with another. It is not allowed to eat two chocolate bars at the same time, to leave the bar unfinished and to make pauses. If both players start to eat the same bar simultaneously, Bob leaves it to Alice as a true gentleman.

How many bars each of the players will consume?

Input

The first line contains one integer n (1 ≤ n ≤ 105) — the amount of bars on the table. The second line contains a sequence t1, t2, ..., tn(1 ≤ ti ≤ 1000), where ti is the time (in seconds) needed to consume the i-th bar (in the order from left to right).

Output

Print two numbers a and b, where a is the amount of bars consumed by Alice, and b is the amount of bars consumed by Bob.

Sample test(s)
input
5
2 9 8 2 7
output
2 3
注意输入的n是1或者是2 的时候要进行特判

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
int a[100002];
int main()
{
    int n,x,y;
    while(~scanf("%d",&n))
    {
        int sum=0;
        int sum1=0;
        int sum2=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        if(n==1)
        {
            printf("1 0\n");
            continue;
        }
        else if(n==2)
        {
            printf("1 1\n");
            continue;
        }
        for(int i=1;i<n;i++)
        {
            sum1+=a[i];
            if(sum1>=sum/2.0)
            {
                sum1-=a[i];
                x=i-1;
                break;
            }
        }
        for(int i=n;i>0;i--)
        {
            sum2+=a[i];
            if(sum2>=sum/2.0)
            {
                sum2-=a[i];
                break;
            }
        }
        //printf("(%d,%d,%d,%d)\n",sum1,sum2,x,n-x);
        if(sum1<=sum2)
            x++;
        printf("%d %d\n",x,n-x);
    }
    return 0;
}


### 如何在 Codeforces 平台上将界面语言设置为中文 Codeforces 是一个国际化的编程竞赛平台,支持多种语言的界面显示,其中包括中文。以下是关于如何将 Codeforces 的界面语言切换到中文的具体方法: #### 1. 登录账户 用户需要先登录自己的 Codeforces 账户。如果尚未注册账户,则需完成注册流程后再进行操作。 #### 2. 进入个人资料页面 点击右上角用户名旁边的下拉菜单选项,在弹出的列表中选择 **Settings**(设置)。此部分允许用户修改各种偏好设定[^1]。 #### 3. 修改语言选项 在 Settings 页面中找到 **Language** 字段,默认可能是 English 或其他语言。通过下拉框可以选择不同的语言选项,其中包含 Simplified Chinese 表示简体中文。选择后保存更改即可生效[^2]。 #### 4. 验证更改效果 返回至首页或其他任意页面确认网站文字已转换成所选目标语言——即中文环境下的表述形式。此时所有的题目描述、公告以及交互提示都将采用中文呈现给用户阅读理解[^3]。 ```python # 示例代码展示如何模拟简单的语言切换逻辑 class UserPreferences: def __init__(self, username): self.username = username self.language = 'English' def set_language(self, new_lang): supported_languages = ['English', 'Simplified Chinese'] if new_lang in supported_languages: self.language = new_lang print(f"Language switched to {new_lang} for user {self.username}.") else: print("Unsupported language.") user = UserPreferences('example_user') user.set_language('Simplified Chinese') # 切换语言为简体中文 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值