[TIOJ] 1409. Knights Of Square

題目連結:http://tioj.infor.org/problems/1409
我被雷了才知道原來多邊形也有任$n-1$邊之和大於第$n$邊的事,所以就掃過去紀錄最大值是誰,然後看$sum-max > max$有沒有成立就好了XD
#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 5;

int main(int argc, char* argv[]){
	int n; 
	while(~scanf("%d",&n)){
		int mx = -1; long long cnt = 0;
		for(int i=0;i<n;i++){
			int x; scanf("%d",&x);
			mx = max(mx, x);
			cnt+=x;
		}
		puts((cnt>(mx<<1))?"YES":"NO");
	}
	return 0;
}

留言

這個網誌中的熱門文章

[NPSC] 2009初賽 E. 檸檬汽水傳說

[TIOJ] 1902. 「殿仁.王,不認識,誰啊?」,然後他就死了……

[AtCoder] [經典競程 90 題] 024 - Select +/- One(★2)