G - MaratonIME does a competition( Gym - 101375G )

G - MaratonIME does a competition

 Gym - 101375G 

Problem Description

Statements

It's January and MaratonIME is attending to an ACM-ICPC Summer School in Campinas. Renzo, THE POWERFUL, went to visit his students and, as usual, brought chocolates from Peru. However, after a couple of parties, MaratonIME is growing a lot and Renzo doesn't have enough chocolates for everyone.

There is enough chocolate for  of the students. So, Renzo will reward the best contestants. As a great coach, Renzo wants MaratonIME to work as a team, so he divided the students in 4 teams,  and . The team which solves more problems wins. If two teams manage to solve the same amount of problems, Renzo rewards the team with smaller lexicographical name (if  and  draw,  gets the chocolates).

In order to assign participants to teams, Renzo found out the amount n of contestants and gave each one of them a different integer from 1 to n. Having numbered the students, Renzo decided that the one with number 1 would go to team , the one with number 2 would go to team  and so on. Formally:

  • The contestant with number 1 is on team 
  • If 1 < i + 1 ≤ n and contestant i is on , then contestant i + 1 is on team 
  • If 1 < i + 1 ≤ n and contestant i is on , then contestant i + 1 is on team 
  • If 1 < i + 1 ≤ n and contestant i is on , then contestant i + 1 is on team 
  • If 1 < i + 1 ≤ n and contestant i is on , then contestant i + 1 is on team 

    There are many students and Renzo is busy thinking about the next contest he's creating, so you were chosen to determine which team wins the big prize! You are given a vector a of size n where, for each index 1 ≤ i ≤ nai is the amount of problems solved by contestant i during the contest. The amount of problems solved by a team is the sum of the problems solved by it's contestants.

Input

The first line of input has an integer 4 ≤ n ≤ 105. The second line, n integers 0 ≤ ai ≤ 104.

Output

You should print one line with name of the team that gets the chocolates:  or .

Example

Input

4
1 2 3 4

Output

D

代码如下:

Hint:本题看上去很长但是需要耐心找关键。其实就是从1到n个学生给出每个学生的做题数量。重要的地方在与将学生分组:1、5、9……是A组,2、4、8……是B组依次类推,一共ABCD组。题目要求输出做题数量最多的一个小组,做题数相同则输出字母序靠前的;

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n, i, k, m;
    long long  a[5] = {0};
    scanf("%d",&n);
    for( i = 1; i <= n; i++)
    {
        k = i;
        while(k > 4)  // 每次循环4个
        {
            k = k - 4;
        }
        scanf("%d",&m);
        a[k] += m;  // 每次将对应的组的学生做的题数累加并存下来
    }
    int max = a[1];
    int j = 1; // 用数字1、2、3、4代替A、B、C、D四个组
    for(i = 2; i <= 4; i++)
    {
        if(max < a[i])
        {
            max = a[i];
            j = i;  // 存下来做题数最大的一组的编号
        }
    }
    for(i = 1; i <= 4 ; i++)
    {
        if(max == a[i] && i != j)
        {
            if(i < j)
            {
                j = i;   // 如果相同做题数,存下来小编号的一组;
            }
        }
    }
    printf("%c\n", 64 + j); // 这里用ASC码转换成字符,A的ASC码为65
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WMYBlog

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值