atcoder 2579
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?
- 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的更多相关文章
- HDU 2579 (记忆化BFS搜索)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2579 题目大意:走迷宫.对于障碍点,只有当前(dep+1)%k才能走,问最少时间. 解题思路: 只有 ...
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识
链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...
- 【HDOJ】2579 Dating with girls(2)
简单BFS. /* 2579 */ #include <iostream> #include <queue> #include <cstdio> #include ...
- AtCoder Regular Contest 082
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...
- AtCoder Regular Contest 069 D
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...
- AtCoder Regular Contest 076
在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...
- AtCoder Grand Contest 016
在雅礼和衡水的dalao们打了一场atcoder 然而窝好菜啊…… A - Shrinking 题意:定义一次操作为将长度为n的字符串变成长度n-1的字符串,且变化后第i个字母为变化前第i 或 i+1 ...
随机推荐
- JAVA基础知识(16)-----Integer
Integer对象数字格式的字符串转成基本数据类型的方法:1:将该字符串封装成了Integer对象,并调用对象的方法intValue();2:使用Integer.parseInt(numstring) ...
- PhoneGap应用图标icon和启动页面SplashScreen
app/config.xml <icon gap:platform="android" gap:qualifier="ldpi" src="re ...
- ASP.NET 连接MySql数据库
ASP.NET Mysql操作类 以下连接MySql数据库以VS2010为例,对于其他的编辑器也差不多 1. 我们需要在Mysql官网下载一个组件http://dev.mysql.com/downlo ...
- AWT简介
-------------siwuxie095 AWT 简介: AWT(Abstract Window Toolkit)是最原始的 Java G ...
- Linux,du、df统计的硬盘使用情况不一致问题
[转]http://blog.linezing.com/?p=2136 Linux,du.df统计的硬盘使用情况不一致问题 在运维Linux服务器时,会碰到需要查看硬盘空间的情况,这时候,通常会使 ...
- Ubuntu重启关机命令使用
如果你想保持当前用户的登录而且使用root用户执行命令 可以输入:su root,输入密码 可以运行,shutdown 命令 重启命令: 1.reboot 2.shutdown -r now 立刻重启 ...
- p2197 nim游戏
传送门 分析 我们知道最后取完的情况就是所有的a[i]异或和为0 所以只要开始的异或和不为0则先手一定可以将它转化为0 否则不行 所以如果异或和非0则先手胜 代码 #include<bits/s ...
- 505C Mr. Kitayuta, the Treasure Hunter
传送门 题目大意 一共有30000个位置,从第0个位置开始走,第一次走k步,对于每一次走步,可以走上一次的ki+1 ,ki ,ki-1步数(必须大于等于1),每个岛上有value,求最大能得到的val ...
- Entity Relationships
Entity Relationships: Here, you will learn how entity framework manages the relationships between en ...
- SSH (Struts2+Spring3.0+Hibernate3)框架(二) 框架的配置
一.准备工作: 1. JDK -> jdk1.6.0_17 安装(环境变量配置): JAVA_HOME = C:\ jdk1.6.0_17; PATH = %JAVA_HOME%\bin; %J ...