• 3.17


    原题链接

    题外话

    今天挺受打击的,这道题看完,我没啥思路,然后先是学弟秒切,后是凯凯秒切后说有个类似题,然后那个类似题我还做过(大哭)

    题意

    挺简单的,就是每次选两个数进行-1操作,问你是否能全部减完

    思路

    (看完类似题之后明白的,类似题网址
    首先要明白一件事 ,如果总和是奇数的,一定无法减完(画图就明白了)
    然后 找到最大值, 与剩下的数进行比较
    - 如果最大值大于剩下的数 ,那么就是no
    - 如果最大值等于小于剩下的数 ,那么就是yes
    其实这里是可以证明,为什么是这样,我们假设三个变量,然后分别是a,b,c(直接定义a>=b>=c)
    - 第一步我们先让a , b 两个数一直减到b ==c
    - 第二步我们把a 剩下的值分配给b,c
    - 第三步我们发现此时情况变为了b 和 c 之和是否为偶数(奇数就代表减不完)
    根据上面的我们就知道了如果b+c >=a(否则一定最后a会有剩下的)的话, 那么在总和不是奇数的前提下,一定是可以分配完的,否则就分配不完

    代码

    ///*
    //正在播放《フリージア》
    //1:21  ━━━━━━●─────   5:35
    //   ?   ?   ??   ?   ?
    //```````'`...```````''`````````````'````````````````'`.`''
    //```````''..`';;'```''```'''''''''''''`````````````````'':
    //.````''''':;;!!:````'````'''''''''''``````````````````'':
    //``''''''':;;;;;'```'``````''```````````____________```'':
    //`````````:;;!;'```````````'```````'```|   所以说   |'``'':
    //```````'|$&$%:````````````'```````````|不要停下来啊|''''':
    //````'''!$&&&|'```````````'''::''::''''/ (指AC)  |':'':::
    //````'':|&&&$!'`````'''''''::.....`;!;'/_________|''``'::
    //  ....'|&&@$!'........```:!;'....`:;:```````````````````'
    //..````;$&&&$!:''``````'':|%%!::;|%$$!::::::::''::::::::::
    //``````!&&@&&|:'````````':|$$$$$$$$$|:':::::::::::::::::::
    //`````:%&@@@@@@@@&&&@@@@&&&&@@@@@@@&&&|::::::::':::::::::;
    //`````.```':|$@@@@@@@@@@@@@@@@@@@@@@@@###@@&&$|;:::'::::::
    //````````````';|$&@@@@@@@@@###@@@@@@########@@@@$!''''::::
    //`````````..````:|%$@@@@@#########@#########@@@@&!''''::::
    //`````````````````:|&########################@@@$;::::::::
    //``````````````````:!$@########################@%;:::'::::
    //``````````..``````':|&#######################@@&!''''''::
    //''''::'''`.`''''''':|@#######################@@&|:'`.`';!
    //:::::::::``'''''';%@######################@@##@@&!::'';;;
    //::;::::::`.''''';%@@@@####################$%@##@@%;:'':;!
    //:;;;;::::``':;%@@@#########################&%&##@@|:'';;!
    //;;!;;;;;;'`::;%@#############################@@##@$!'';!!
    //;;;;;;;;:``':::::;|$@############################@$!'`;!!
    //::;;;;;;:'`'::::::;!$@#######################&&@$$$;``:;;
    //`````````..````````'|@#####################$;!$$$&@@|''':
    //'''''''''''''':'''''|@#########@&@##########@@####@@&%|!!
    //''''''''':'''::'':''!&########&!|&@##########&&####&%|!||
    //:::::'''::::::::::::!&########|:;|$@#########@&###&%||||!
    //:::::::'''''':::::::!&#######@!:;!!$@########@$&##@%||||!
    //
    //                    だからよ...止まるじゃねえぞ
    // */
    //
    //
    
    
    #include <vector>
    #include <algorithm>
    #include <string>
    #include<cstring>
    #include <iostream>
    #include <set>
    #include <map>
    #include <stack>
    #include <queue>
    #include <unordered_map>
    #include <bitset>
    #include <cassert>
    #include <chrono>
    #include <random>
    #include <iomanip>
    #include <unordered_set>
    #include <ctime>
    #include <chrono>
    using namespace std;
    // #define  ll long long
    const int N =1e5+10;
    #define PII pair<int , int > 
    #define all(x) (x).begin(),(x).end()
    #define rall(x) (x).rbegin(),(x).rend()
    #define pb push_back
    #define sz(x) (int)(x).size()
    typedef long long ll;
    typedef long double ld;
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n , m ,t ;
    ll ar[1000010];
    bool st[N];
    string s[1010];
    bool cmp(const pair<PII,int> &p1, const pair<PII,int> &p2) {
        return p1.second > p2.second;
    }
    //ll mod = 1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0), cout.tie(0);
    	cin >>n;
    	ll sum =0 ;ll ma =0 ;
    	for(int i=0;i<n;i++)
    	{
    		cin >>m ; ma =max(ma, m);sum +=m;
    		
    	}
    	//cout<<sum<<endl;
    	if(sum%2==1 || sum-ma<ma) cout<<"NO"<<endl;
    	else cout<<"Yes"<<endl;
        return 0;
    
    }
    /*
     * 5
    4 100
    0 0 0 0
    1 2
    1
    3 4
    1 4 1
    3 2
    0 1 3
    3 9
    0 59049 810
    */
    
  • 相关阅读:
    IOS开发-CALayer和UIView详细汇总
    IOS开发-第三方SDWebImage下载网络图片的使用
    解决TalbleView头部或底部子控件不显示问题
    node.js http.get 和http.post 数据
    Node.js Express 获取request原始数据
    个人开发者做一款Android App需要知道的事情
    个人开发者的酸甜苦辣
    码农的福利来了, 编程在线Androd 客户端上线了
    console使用技巧
    AngularJS 常用语法
  • 原文地址:https://www.cnblogs.com/gaohaoy/p/12509814.html
Copyright © 2020-2023  润新知