Description
Submission
class Solution { public: bool isPossible(vector<int>& target) { priority_queue<int> pq; long long sum = 0; for(auto t: target) { pq.push(t); sum += t; } while(pq.top() != 1) { long long t = pq.top(); pq.pop(); long long others = sum - t; if(others == 0) return false; if(t <= others) return false; t = t % others; sum = others + t; pq.push(t); } return true; } };