考えられる投票者数の最大最小を見る。
class ElectionFraudDiv2 { public: string IsFraudulent(vector <int> P) { const int N = 10000; int mn = 0; int mx = 0; for (int i = 0; i < (int)P.size(); ++i) { mx += P[i] * 100 + 49; if (P[i]) mn += P[i] * 100 - 50; } if (mn <= N && N <= mx) return "NO"; return "YES"; } };