• 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?


    Constraints
    • All input values are integers.
    • 1N100
    • 1si100
    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;
    			}
    		}
    	}
    }
    
    EPFL - Fighting
  • 相关阅读:
    我爱工程化 之 gulp 使用(二)
    我爱工程化 之 gulp 使用(一)
    用户体验之输入框设想
    SEO优化
    js代码优化
    RequireJs 依赖管理使用
    Git 安装与使用(一)
    Webstorm 配置与使用 Less
    Less使用——让老司机带你飞
    Node安装与环境配置
  • 原文地址:https://www.cnblogs.com/zxyqzy/p/10319167.html
Copyright © 2020-2023  润新知