You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is si. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well.

However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?

Constraints

  • All input values are integers.
  • 1≤N≤100
  • 1≤si≤100

Input

Input is given from Standard Input in the following format:

N
s1
s2
:
sN

Output

Print the maximum value that can be displayed as your grade.

Sample Input 1

3
5
10
15

Sample Output 1

25

Your grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.

Sample Input 2

3
10
10
15

Sample Output 2

35

Your grade will be 35 if all the questions are answered correctly, and this grade will be displayed correctly.

Sample Input 3

3
10
20
30

Sample Output 3

0

Regardless of whether each question is answered correctly or not, your grade will be a multiple of 10 and displayed as 0.

问可以最大得到的分数且不能被10整除;

我之前考虑的是dp,发现不太对;

其实:如果所有的数都是10的倍数的话,那么答案就为0;

否则我们减去一个最小的且不为10的倍数的数即可;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline LL rd() {
LL x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} /*ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }
*/ /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int n; int a[maxn]; int main() {
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;int sum=0;
bool fg=1;
for(int i=1;i<=n;i++)rdint(a[i]),sum+=a[i];
for(int i=1;i<=n;i++){
if(a[i]%10!=0)fg=0;
}
if(fg==1){
cout<<0<<endl;return 0;
}
if(sum%10!=0){
cout<<sum<<endl;
}
else{
sort(a+1,a+1+n);
for(int i=1;i<=n;i++){
if((sum-a[i])%10!=0){
cout<<sum-a[i]<<endl;
return 0;
}
}
}
}

atcoder 2579的更多相关文章

  1. HDU 2579 (记忆化BFS搜索)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2579 题目大意:走迷宫.对于障碍点,只有当前(dep+1)%k才能走,问最少时间. 解题思路: 只有 ...

  2. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  3. hdu 2579 Dating with girls(2)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...

  4. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  5. 【HDOJ】2579 Dating with girls(2)

    简单BFS. /* 2579 */ #include <iostream> #include <queue> #include <cstdio> #include ...

  6. AtCoder Regular Contest 082

    我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...

  7. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

  8. AtCoder Regular Contest 076

    在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...

  9. AtCoder Grand Contest 016

    在雅礼和衡水的dalao们打了一场atcoder 然而窝好菜啊…… A - Shrinking 题意:定义一次操作为将长度为n的字符串变成长度n-1的字符串,且变化后第i个字母为变化前第i 或 i+1 ...

随机推荐

  1. appium-unittest框架中的断言

    1.首先unittest本身是一个python的测试框架,他有他自己的使用规则: 2.如果用其中的方法,需要引入,方法: import unittest class Login(unittest.Te ...

  2. Python函数(八)-装饰器(一)

    装饰器通过函数来定义,用来装饰函数 装饰器的结构为高阶函数和内嵌函数 装饰器不改变被装饰函数的源代码和运行方式 如何实现这个效果呢? # -*- coding:utf-8 -*- __author__ ...

  3. leetcode589

    树的先序遍历,使用递归实现. class Solution { public: vector<Node> Tree; void preTree(Node node) { Tree.push ...

  4. java 截取替换掉括号 包括括号中的内容

    public static void main(String[] args) { String company = "华厦世纪(厦门)地产"; // System.out.prin ...

  5. spring----AOP注解以及spring的JDBC和事务

    技术分析之:Spring框架的AOP技术(注解方式) 1. 步骤一:创建JavaWEB项目,引入具体的开发的jar包 * 先引入Spring框架开发的基本开发包 * 再引入Spring框架的AOP的开 ...

  6. Ros学习——roslaunch

    roslaunch:启动定义在launch文件中的多个节点 1.launch文件解析 <launch> #以launch标签开头以表明这是一个launch文件 #两个节点分组并以'命名空间 ...

  7. tab页以及jqgrid某些用法参考记录

    <%@ Page Language="C#" AutoEventWireup="True" CodeBehind="CcrCreditHuman ...

  8. SDUT 1489 求二叉树的先序遍历 (中序后序还原二叉树)

    求二叉树的先序遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Description  已知一 ...

  9. Spark 1.4.1中Beeline使用的gc overhead limit exceeded

    最近使用SparkSQL做数据的打平操作,就是把多个表的数据经过关联操作导入到一个表中,这样数据查询的过程中就不需要在多个表中查询了,在数据量大的情况下,这样大大提高了查询效率.   我启动了thri ...

  10. Bootstrap 组件之 Panel

    一.简介 Panel 指面板.这里 有例子. 一个典型的面板的代码结构是这样的: .panel.panel-default .panel-heading .panel-title Title Text ...