G - MaratonIME does a competition

简介: G - MaratonIME does a competition

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 ≤ n, ai 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

题目大意及思路:给你N个数,第一个数去1队,第二个数去2队,第三个数去3队,第4个数去4队,以此类推。最后那个队伍的和最多,输出相对应的ABCD

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n, sum1, sum2, sum3, sum4, i;
    int a[100100];
    int b[101];
    sum1 = sum2 = sum3 = sum4 = 0;
    scanf("%d", &n);
    for(i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        if(i % 4 == 1)
        {
            sum1 = sum1 + a[i];
        }
        if(i % 4 == 2)
        {
            sum2 = sum2 + a[i];
        }
        if(i % 4 == 3)
        {
            sum3 = sum3 + a[i];
        }
        if(i % 4 == 0)
        {
            sum4 = sum4 + a[i];
        }
    }
    int max = sum1;
    b[1] = sum1;
    b[2] = sum2;
    b[3] = sum3;
    b[4] = sum4;
    for(i = 1; i <= 4; i++)
    {
        if(b[i] > max)
        {
            max = b[i];
        }
    }
    for(i = 1; i <= 4; i++)
    {
        if(b[i] == max)
        {
            break;
        }
    }
    if(i == 1)
    {
        printf("A\n");
    }
    if(i == 2)
    {
        printf("B\n");
    }
    if(i == 3)
    {
        printf("C\n");
    }
    if(i == 4)
    {
        printf("D\n");
    }
    return 0;
}


相关文章
TimeInterval value and value2 determination in SalesPipeline
TimeInterval value and value2 determination in SalesPipeline
85 0
TimeInterval value and value2 determination in SalesPipeline
|
Python
lecture 1 练习
Assume that two variables, varA and varB, are assigned values, either numbers or strings.
1079 0
[Everyday Mathematics]20150220
试求 $$\bex \sum_{k=0}^\infty\frac{1}{(4k+1)(4k+2)(4k+3)(4k+4)}. \eex$$
501 0
[Everyday Mathematics]20150223
是否存在 $3\times 3$ 阶实方阵 $A$ 使得 $\tr A=0$ 且 $A^2+A^T=I$?
514 0
[Everyday Mathematics]20150218
设 $A,B$ 是 $n$ 阶复方阵, 适合 $$\bex A^2B+BA^2=2ABA. \eex$$ 试证: 存在 $k\in\bbZ^+$, 使得 $(AB-BA)^k=0$.
475 0
[Everyday Mathematics]20150224
设 $A,B$ 是 $n$ 阶实对称矩阵, 它们的特征值 $>1$. 试证: $AB$ 的特征值的绝对值 $>1$.
452 0
[Everyday Mathematics]20150208
对 $f\in C^2(\bbR)$ 适合 $$\bex \vlm{|x|}f(x)=0, \eex$$ 试证: $$\bex \int_{\bbR} |f'|^p\rd x \leq (p-1)^\frac{p}{2}\int_{\bbR} |ff''|^\frac{p}{2} \rd x,\quad p\geq 2.
431 0
[Everyday Mathematics]20150130
计算下列积分 $$\bex \int_0^\infty \frac{\sin^3x}{x^3}\rd x. \eex$$
661 0