1711 C
user_6698603632
plain_text
2 years ago
1.4 kB
4
Indexable
Never
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define F first #define S second #define Tsetso ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); const int N = 2e5+50 , length = 25 , mod = 1e9+7; string find_ans(vector <int> v, int m, int n, int k); int main() { int c; cin >> c; string ans = ""; while(c--) { int m, n, k,i; cin >> m; cin >> n; cin >> k; i = k; vector <int> v; while(i--) { int temp; cin >> temp; v.push_back(temp); } sort(v.begin(), v.end(), greater <>()); ans = ans + find_ans(v, m, n, k); } cout << ans; return 0; } string find_ans(vector <int> v, int m, int n, int k) { int rc; int sum = 0; if (n == 3 && v[0]/m >= 3) return "Yes\n"; else { if (m == 3 && v[0]/n >= 3) return "Yes\n"; else if(m == 3) return "No\n"; } for (int i = 0; i < k; i++) { rc = v[i] / m; if(rc < 2) rc = 0; sum = sum + rc; } if (sum >= n) return "Yes\n"; else { sum = 0; for (int i = 0; i < k; i++) { rc = v[i] / n; if(rc < 2) rc = 0; sum = sum + rc; } if (sum >= m) return "Yes\n"; return "No\n"; } }