text
stringlengths
49
983k
#include <bits/stdc++.h> int main() { long currentMax(0), total(0); long n(0), s(0); scanf("%ld %ld\n", &n, &s); while (n--) { int temp(0); scanf("%d", &temp); if (temp > currentMax) { currentMax = temp; } total += temp; } total -= currentMax; if (total <= s) { puts("YES"); } else { puts("NO"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, t, i, sum, s; while (cin >> n >> s) { int max = 0; sum = 0; for (i = 1; i <= n; i++) { cin >> t; sum = sum + t; if (t >= max) { max = t; } } sum = sum - max; if (sum > s) { cout << "NO" << endl; } if (sum <= s) { cout << "YES" << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; void c_p_n() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool comp(pair<long long, long long> a, pair<long long, long long> b) { return abs(b.first) > abs(a.first); } int32_t main() { c_p_n(); long long n, s; cin >> n >> s; long long a[n]; for (long long i = 0; i <= n - 1; i++) cin >> a[i]; sort(a, a + n); long long sumi = 0; for (long long i = 0; i <= n - 2; i++) sumi += a[i]; sumi <= s ? cout << "YES\n" : cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int di4[] = {0, 0, 1, -1}, dj4[] = {-1, 1, 0, 0}; int di8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dj8[] = {-1, 1, -1, 0, 1, -1, 0, 1}; int di6[] = {-1, 0, 1, -1, 0, 1}, dj6[] = {-1, -1, 0, 0, 1, 1}; int GCD(int a, int b) { if (!b) return a; return GCD(b, a % b); } int LCM(int a, int b) { return ((a * b) / GCD(a, b)); } int mod(int a, int b) { return (a % b + b) % b; } unsigned long long choose(unsigned long long n, unsigned long long k) { if (k > n) { return 0; } unsigned long long r = 1; for (unsigned long long d = 1; d <= k; ++d) { r *= n--; r /= d; } return r; } int main() { int n, s; cin >> n >> s; int a[110], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < n - 1; i++) { sum += a[i]; } cout << (sum > s ? "NO" : "YES") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, h, m, l, r, x; cin >> n >> m; int a, max = 0, sum = 0; for (int i = 0; i < n; i++) { cin >> a; sum += a; if (a > max) max = a; } sum -= max; if (m >= sum) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, i, a[105]; long long ans = 0; cin >> n >> s; for (i = 0; i < n; i++) { cin >> a[i]; ans += a[i]; } sort(a, a + n); ans -= a[n - 1]; if (ans <= s) { cout << "YES"; } else { cout << "NO"; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, s, i, l, sum; vector<int> a; int main() { cin >> n >> s; for (; i < n; i++) { cin >> l; a.push_back(l); } sort(a.begin(), a.end()); for (i = 0; i < n - 1; i++) { sum += a[i]; } if (sum <= s) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, a, x(0), maxi(0); cin >> n >> s; for (int k = 0; k < n; k++) { cin >> a; x += a; if (maxi < a) { maxi = a; } } if (x - maxi > s) { cout << "NO"; } else { cout << "YES"; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, h, s, c, mx; int main() { cin >> n >> h; for (int i = 0; i < n; i++) { cin >> c; if (mx < c) mx = c; s += c; } if (s - mx <= h) { cout << "YES"; } else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, i, a, max = -1; cin >> n >> s; for (i = 0; i < n; i++) { cin >> a; s -= a; if (a > max) max = a; } if (s + max >= 0) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, cnt = 0; cin >> n >> s; int arr[100]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int i = 0; i < n - 1; i++) s -= arr[i]; if (s >= 0) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, x, maxx = 0, sum = 0; scanf("%d%d", &n, &s); for (int i = 0; i < n; i++) { scanf("%d", &x); if (x > maxx) maxx = x; sum += x; } sum -= maxx; if (sum <= s) puts("YES"); else puts("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int a[111111]; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n - 1; ++i) s -= a[i]; if (s >= 0) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; vector<int> vt; int z; for (int i = 0; i < n; i++) { cin >> z; vt.push_back(z); } int maxi = max_element(vt.begin(), vt.end()) - vt.begin(); int sum; for (int i = 0; i < n; i++) { sum += vt[i]; } int result = sum - vt[maxi]; if (result <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n, s; cin >> n >> s; vector<ll> A(n); for (auto& _a : A) cin >> _a; sort(A.begin(), A.end()); ll sum = accumulate(A.begin(), A.end() - 1, 0LL); if (s >= sum) { cout << "YES" << '\n'; } else { cout << "NO" << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, number[1001], s, temp, number1[1001]; while (scanf("%d", &n) == 1) { cin >> s; for (int i = 1; i <= n; i++) { cin >> number[i]; } for (int i = 1; i <= n - 1; i++) { for (int j = 1; j <= n - i; j++) { if (number[j] > number[j + 1]) { temp = number[j + 1]; number[j + 1] = number[j]; number[j] = temp; } } } int sum = 0; for (int i = 1; i < n; i++) sum = sum + number[i]; if (sum <= s) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, sum = 0; cin >> n >> s; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (int i = 0; i < n - 1; i++) { sum += arr[i]; } if (sum > s) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> int main(void) { int n, s; scanf("%d %d", &n, &s); int ara[n], big = 0, total = 0, i; for (i = 0; i < n; i++) { scanf("%d", &ara[i]); total = total + ara[i]; if (ara[i] > big) { big = ara[i]; } } if ((total - big) > s) { printf("NO"); } else { printf("YES"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int hrnky[n]; int max = 0; int soucet = 0; for (int a = 0; a < n; a++) { cin >> hrnky[a]; soucet = soucet + hrnky[a]; if (hrnky[a] > max) { max = hrnky[a]; } } int b = soucet - max; if (b > s) { cout << "NO"; } else { cout << "YES"; } return 0; }
#include <bits/stdc++.h> int main() { using namespace std; int a[110], n, v, t = 0; cin >> n >> v; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); for (int i = 0; i < n - 1; i++) t += a[i]; if (t <= v) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int mm = -1, sum = 0; for (int i = 0; i < n; i++) { int a; cin >> a; sum += a; mm = max(mm, a); } if (sum - mm > m) { cout << "NO" << endl; } else { cout << "YES" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int b[100]; bool f = false; for (int i = 0; i < n; i++) { cin >> b[i]; } int sum = 0; int max = b[0]; sum += b[0]; for (int i = 1; i < n; i++) { sum += b[i]; if (max <= b[i]) max = b[i]; } if ((sum - max) <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> const int maxi = 1001; using namespace std; int main() { cin.tie(0); std::ios::sync_with_stdio(false); vector<int> pq; int n, v_cup, sum = 0, v_mug; cin >> n >> v_cup; for (int i = 0; i < n; i++) { cin >> v_mug; pq.push_back(v_mug); } sort(pq.begin(), pq.end()); for (int i = 0; i < n - 1; i++) sum += pq[i]; if (sum <= v_cup) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a, s = 0, mx = 0; cin >> n >> k; for (int i = 0; i < n; ++i) { cin >> a; mx = max(mx, a); s += a; } s -= mx; cout << ((s <= k) ? "YES\n" : "NO\n"); }
#include <bits/stdc++.h> int main(void) { int n, s; scanf("%d%d", &n, &s); int m = -1; for (int zz = 0; zz < (n); zz = zz + 1) { int v; scanf("%d", &v); if (m < v) m = v; s -= v; } if (s + m >= 0) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, i, sm = 0, mx = 0, t; cin >> n >> s; for (i = 0; i < n; i++) { cin >> t; sm += t; if (mx < t) mx = t; } sm -= mx; if (sm <= s) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, num, maxx = -1, sum; cin >> n >> s; sum = 0; while (n--) { cin >> num; int n = num; if (maxx < num) { maxx = num; } sum += n; } if (sum - maxx > s) cout << "NO" << endl; else cout << "YES" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, m[100]; cin >> n >> s; for (int i = 0; i < n; i++) cin >> m[i]; sort(m, m + n); for (int i = 0; i < n - 1; i++) s -= m[i]; cout << (s >= 0 ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1010; int n, v; int a[N]; int main() { scanf("%d%d", &n, &v); int m = 0, sum = 0; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); sum += a[i]; if (a[i] > m) m = a[i]; } if (sum - m > v) printf("NO\n"); else printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int in[140]; int main() { int n, m; cin >> n >> m; bool suc = true; int sum = 0, mn = -1; while (n--) { int tmp; cin >> tmp; sum += tmp; mn = ((tmp) > (mn) ? (tmp) : (mn)); } sum -= mn; if (sum > m) suc = false; if (suc) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; template <typename T, typename T1> T amax(T a, T1 b) { if (b > a) a = b; return a; } template <typename T, typename T1> T amin(T a, T1 b) { if (b < a) a = b; return a; } template <typename T> T amod(T a) { if (a < 0) a = -a; return a; } void solve() { long long int n, s, a, sum = 0; cin >> n >> s; long long int maxs = 0; for (long long int i = 0; i < n; i++) { cin >> a; sum += a; maxs = max(a, maxs); } if ((sum - maxs) <= s) { cout << "YES"; } else { cout << "NO"; } } int main() { long long int t; t = 1; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, tem; int sum = 0, max = 0; cin >> n >> s; for (int i = 0; i < n; ++i) { cin >> tem; sum += tem; if (tem > max) { max = tem; } } if (sum - max > s) { cout << "NO" << endl; } else { cout << "YES" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, mag[101], vol = 0; cin >> n >> s; for (int i = 0; i < n; i++) { cin >> mag[i]; vol = vol + mag[i]; } int max = mag[0]; int index = 0; for (int i = 1; i < n; i++) { if (max <= mag[i]) { max = mag[i]; index = i; } } vol = vol - mag[index]; if (vol <= s) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, m[100]; cin >> n >> s; for (int i = 0; i < n; i++) cin >> m[i]; sort(m, m + n); for (int i = 0; i < n - 1; i++) { s -= m[i]; } cout << (s >= 0 ? "YES" : "NO") << endl; return 0; }
#include <bits/stdc++.h> int main() { int n, s, i, j, a[105], total, rr, check; while (scanf("%d%d", &n, &s) != EOF) { for (i = 0; i < n; i++) scanf("%d", &a[i]); check = 0; total = 0; for (j = 0; j < n; j++) total = total + a[j]; for (i = 0; i < n; i++) { rr = total - a[i]; if (rr <= s) { printf("YES\n"); check = 1; break; } } if (check != 1) printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> string to_str(T str) { stringstream stream; stream << str; return stream.str(); } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, s; cin >> n >> s; vector<int> v; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); } int sum = 0; sort(v.begin(), v.end()); for (int i = 0; i < n - 1; i++) { sum += v[i]; } if (sum <= s) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int n, s, a[107], sum = 0; scanf("%d %d", &n, &s); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); sum += a[i]; } bool flag = false; for (int i = 1; i <= n; i++) { if (sum - a[i] <= s) { flag = true; break; } } if (flag) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n, s; cin >> n >> s; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int sum = 0; for (int i = 0; i < n; i++) { sum += a[i]; } sort(a.begin(), a.end()); if (sum - a[n - 1] <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int n, s, a[101], sum; int main() { cin >> n >> s; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); for (int i = 1; i <= n - 1; i++) sum += a[i]; if (sum > s) cout << "NO"; else cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; static const int mod = 1e9 + 7; void cj() { int tt; cin >> tt; for (int qq = 1; qq <= tt; ++qq) { cout << "Case #" << qq << ": "; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, s; cin >> n >> s; int mx = -1; int sum = 0; for (int i = 0; i < n; ++i) { int t; cin >> t; sum += t; mx = max(mx, t); } sum -= mx; if (s - sum >= 0) { cout << "YES" << '\n'; ; } else { cout << "NO" << '\n'; ; } return 0; }
#include <bits/stdc++.h> using namespace std; void solve(); const int N = 10000005; int i, n, sum; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { solve(); cout << "\n"; } return 0; } void solve() { int s; cin >> n >> s; int a[n]; int ma = INT_MIN; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; ma = max(ma, a[i]); } if (sum - ma <= s) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, a[101], s = 0; cin >> n >> k; for (i = 1; i <= n; i++) { cin >> a[i]; s += a[i]; } sort(a + 1, a + n + 1); s -= a[n]; if (s <= k) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[1003]; char s[1003]; int main() { int i, j, k, ans, n, m; cin >> n >> m; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); k = j = 0; for (i = 0; i < n - 1; i++) { if (j + a[i] <= m) { j += a[i]; } else k = 1; } if (k == 0) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, s, a[105]; scanf("%d%d", &n, &s); y = 0; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); for (int i = 1; i < n; i++) y += a[i]; if (y > s) printf("NO\n"); else printf("YES\n"); }
#include <bits/stdc++.h> using namespace std; int s, n, mugs[110], aux; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s; for (int i = 0; i < n; i++) cin >> mugs[i]; sort(mugs, mugs + n); for (int i = 0; i < n - 1; i++) aux += mugs[i]; if (aux <= s) { cout << "YES"; } else cout << "NO"; }
#include <bits/stdc++.h> int main() { int n, s, max, i = 0, sum = 0, a[100]; scanf("%d%d", &n, &s); for (i = 0; i < n; i++) { scanf("%d", &a[i]); sum = sum + a[i]; } max = a[0]; for (i = 0; i < n; i++) { if (a[i] > max) { max = a[i]; } } if ((sum - max) <= s) { printf("YES\n"); } else { printf("NO\n"); } return 0; }
#include <bits/stdc++.h> const double E = 2.7182818284590452353602874713527; using namespace std; char ch[1000000], ch1[1000000]; long ara[1000000], ara1[1000000]; int main() { long i, j, k, res, num, cnt = 0, n, sum = 0, s; scanf("%ld %ld", &n, &s); for (i = 0; i < n; i++) { scanf("%ld", &ara[i]); } num = n - 1; sort(ara, ara + n); for (i = 0; i < n - 1; i++) { sum += ara[i]; } if (sum <= s) { printf("YES\n"); } else { printf("NO\n"); } return 0; }
#include <bits/stdc++.h> int main() { int n, s, i, a[100]; int sum = 0; scanf("%d %d", &n, &s); for (i = 0; i < n; i++) { scanf("%d", &a[i]); sum = sum + a[i]; } int max = a[0]; for (i = 0; i < n; i++) { if (a[i] > max) max = a[i]; } sum -= max; if (sum <= s) printf("YES\n"); else printf("NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n]; int sum = 0; int maxi = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum = sum + a[i]; if (a[i] > maxi) { maxi = a[i]; } } int ans = sum - maxi; if (ans <= m) { cout << "YES" << endl; } else { cout << "NO" << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int x = 0; int n, z, m; int y = 0; cin >> n >> z; while (n > 0) { cin >> m; x += m; if (m > y) y = m; n--; } if ((x - y) > z) cout << "NO"; else cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a[200], j, max1 = 0, s, s0 = 0; scanf("%d%d", &n, &s); for (i = 0; i < n; i++) { scanf("%d", &a[i]); s0 += a[i]; if (max1 < a[i]) max1 = a[i]; } if (s0 - max1 > s) printf("NO\n"); else printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int cnt, element; int main() { int m, n, x, mx = 0, sum = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; mx = max(mx, x); sum = sum + x; } sum = sum - mx; if (sum <= m) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); inline int sgn(double x) { return fabs(x) < 1e-6 ? 0 : (x < 0 ? -1 : 1); } int main() { int n, v; while (scanf("%d%d", &n, &v) + 1) { int a[1005] = {0}; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int sum = 0; for (int i = 0; i < n - 1; i++) { sum += a[i]; } if (sum > v) { printf("NO\n"); } else printf("YES\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, v, i; cin >> n >> v; long long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < n - 1; i++) v -= a[i]; if (v >= 0) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int n, s, a, ans, ma; int main() { cin >> n >> s; for (int i = 1; i <= n; i++) { cin >> a; ans = ans + a; if (a > ma) { ma = a; } } ans = ans - ma; if (ans <= s) { cout << "YES"; } else { cout << "NO"; } return 0; }
#include <bits/stdc++.h> int main() { int n, s, sum, max; scanf("%d%d", &n, &s); max = sum = 0; while (n--) { int a; scanf("%d", &a); sum += a; if (max < a) max = a; } sum -= max; printf(sum <= s ? "YES\n" : "NO\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, s, m = 0, sum = 0, inp; cin >> n >> s; for (int(i) = (0); (i) < (n); (i)++) { cin >> inp; m = max(m, inp); sum += inp; } sum -= m; if (sum <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; int a[1005]; long long read() { long long w = 1, c, ret; while ((c = getchar()) > '9' || c < '0') w = (c == '-' ? -1 : 1); ret = c - '0'; while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + c - '0'; return ret * w; } int main() { int n, s; n = read(); s = read(); for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); int sum = 0; for (int i = 1; i < n; i++) { sum += a[i]; } if (sum > s) cout << "NO"; else cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return (a - b) ? gcd(a - b, b) : a; } void solve() { int n, s, x, m = -1; cin >> n >> s; for (int i = 0; i < n; i++) { cin >> x; if (m < x) m = x; s -= x; } if (s + m < 0) cout << "NO"; else cout << "YES"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, k; k = 0; cin >> n >> s; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.rbegin(), a.rend()); for (int i = 1; i < n; i++) k += a[i]; if (k <= s) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> int cmp(const void *a, const void *b) { if (*(int *)a > *(int *)b) { return 1; } return -1; } int main() { int i, j, k, l, m, s, n, pl; int a[101]; while (~scanf("%d %d", &n, &s)) { k = 0; pl = 0; for (i = 0; i < n; i++) { scanf("%d", &a[i]); } qsort(a, n, sizeof(a[0]), cmp); for (i = 0; i < n - 1; i++) { k += a[i]; } if (k <= s) { puts("YES"); } else { puts("NO"); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, s; cin >> n >> s; vector<int> mug(n); for (long long i = 0; i < n; i++) cin >> mug[i]; sort(mug.begin(), mug.end()); int sum = 0; for (long long i = 0; i < n - 1; i++) sum += mug[i]; if (sum <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; int a[110]; scanf("%d%d", &n, &s); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int ans = accumulate(a, a + n - 1, 0); if (ans <= s) puts("YES"); else puts("NO"); return 0; }
#include <bits/stdc++.h> int main() { int n, s; int i, j, k, temp, index, check = 0; int vol[10000]; scanf("%d %d", &n, &s); temp = 0; for (i = 0; i < n; i++) { scanf("%d", &vol[i]); if (vol[i] > temp) { temp = vol[i]; index = i; } } for (i = 0; i < n; i++) { if (i != index) { check = check + vol[i]; } } if (check > s) { printf("NO\n"); } else { printf("YES\n"); } return 0; }
#include <bits/stdc++.h> int main() { int n, s, i, j, a[105], total, check; while (scanf("%d%d", &n, &s) != EOF) { for (i = 0; i < n; i++) scanf("%d", &a[i]); check = 0; for (i = 0; i < n; i++) { total = 0; for (j = 0; j < n; j++) total = total + a[j]; total = total - a[i]; if (total <= s) { printf("YES\n"); check = 1; break; } } if (check != 1) printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int n, s, t, maxn = -1e9, sum; int main() { scanf("%d%d", &n, &s); for (int i = 1; i <= n; i++) { scanf("%d", &t); maxn = max(maxn, t); sum += t; } sum -= maxn; if (sum <= s) { printf("YES"); } else { printf("NO"); } return 0; }
#include <bits/stdc++.h> using namespace std; int a, sum = 0, n, m, s = 0; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a; sum += a; if (a > s) s = a; } if (sum - s > m) cout << "NO"; else cout << "YES"; return 0; }
#include <bits/stdc++.h> int n, s, x, mx, sum; int main() { scanf("%d%d", &n, &s); for (register int i = 0; i < n; ++i) { scanf("%d", &x); sum += x; if (x > mx) mx = x; } if (sum - mx > s) printf("NO\n"); else printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, v, arr[100000], c = 0, b = 0; cin >> n >> v; for (long long i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (long long i = 0; i < n; i++) { if (c + arr[i] <= v) { c = c + arr[i]; b = b + 1; } } if (b == n || n - b == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> T Sqr(T x) { T n = x * x; return n; } template <typename T> T Pow(T B, T P) { if (P == 0) return 1; if (P & 1) return B * Pow(B, P - 1); else return Sqr(Pow(B, P / 2)); } template <typename T> T Abs(T a) { if (a < 0) return -a; else return a; } template <typename T> T Gcd(T a, T b) { if (a < 0) return Gcd(-a, b); if (b < 0) return Gcd(a, -b); return (b == 0) ? a : Gcd(b, a % b); } template <typename T> T Lcm(T a, T b) { if (a < 0) return Lcm(-a, b); if (b < 0) return Lcm(a, -b); return a * (b / Gcd(a, b)); } template <typename T> T Exgcd(T a, T b, T &x, T &y) { if (a < 0) { T d = Exgcd(-a, b, x, y); x = -x; return d; } if (b < 0) { T d = Exgcd(a, -b, x, y); y = -y; return d; } if (b == 0) { x = 1; y = 0; return a; } else { T d = Exgcd(b, a % b, x, y); T t = x; x = y; y = t - (a / b) * y; return d; } } template <typename T> T BigMod(T b, T p, T m) { if (p == 0) return 1; if (p % 2 == 0) { T s = BigMod(b, p / 2, m); return ((s % m) * (s % m)) % m; } return ((b % m) * (BigMod(b, p - 1, m) % m)) % m; } template <typename T> T ModInvPrime(T b, T m) { return BigMod(b, m - 2, m); } template <typename T> T ModInvNotPrime(T a, T m) { T x, y; Exgcd(a, m, x, y); x %= m; if (x < 0) x += m; return x; } template <typename T> inline string ToBinary(T n) { string r; while (n != 0) { r = (n % 2 == 0 ? "0" : "1") + r; n >>= 1; } return r; } template <typename T> void Print(T ar[], int a, int b) { for (int i = a; i + 1 <= b; i++) cout << ar[i] << " "; cout << ar[b] << "\n"; } template <typename T> void Print(T ar[], int n) { for (int i = 0; i + 1 < n; i++) cout << ar[i] << " "; cout << ar[n - 1] << "\n"; } template <typename T> typename std::vector<T>::iterator Insert_sorted(std ::vector<T> &vec, T const &item) { return vec.insert(std::upper_bound(vec.begin(), vec.end(), item), item); } char Uplowch(char ch) { if (ch >= 'A' && ch <= 'Z') ch += 32; return ch; } char Lowupch(char ch) { if (ch >= 'a' && ch <= 'z') ch -= 32; return ch; } bool Isalpha(char ch) { if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return true; return false; } long long Strtoint(string str) { stringstream ss(str); long long x = 0; ss >> x; return x; } string Intostr(long long x) { stringstream ss; ss << x; string str = ss.str(); return str; } vector<string> Linetostr(string str) { string s; vector<string> v; istringstream is(str); while (is >> s) v.push_back(s); return v; } const double pi = 2 * acos(0.0); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, s; cin >> n >> s; int ar[n + 5]; for (int i = 1; i <= n; i++) cin >> ar[i]; sort(ar + 1, ar + n + 1); int sum = 0; for (int i = 1; i < n; i++) sum += ar[i]; if (sum <= s) cout << "YES\n"; else cout << "NO\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int ans = 0, max = 0, x; for (int i = 0; i < n; i++) { cin >> x; ans += x; if (x > max) max = x; } ans -= max; if (ans <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; const int M = 105; int a[M]; int main() { int n, v, i, j, k; while (~scanf("%d%d", &n, &v)) { int mx = 0; k = 0; for (i = 0; i < n; i++) { scanf("%d", &a[i]); k += a[i]; mx = max(mx, a[i]); } if (k - mx > v) puts("NO"); else puts("YES"); } return 0; }
#include <bits/stdc++.h> using namespace std; int a[10001]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n - 1; i++) k -= a[i]; if (k < 0) cout << "NO"; else cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int main() { int s, n, a[1005]; while (cin >> n >> s) { int sum = 0, ma; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] >= ma) { ma = a[i]; } sum = sum + a[i]; } if (sum - ma <= s) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long l, r, k, i, n, j, p, q, a, b, m; while (cin >> n >> m) { int ara[n + 1]; ara[0] = -1; for (i = 1; i <= n; i++) cin >> ara[i]; bool flag = 0; sort(ara, ara + n + 1); for (i = 1; i < n; i++) { if (ara[i] > m) { flag = 1; break; } else m -= ara[i]; } if (flag) cout << "NO\n"; else cout << "YES\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = int(1e9 + 7); ifstream fcin(""); ofstream fcout(""); int main() { int n, v; cin >> n >> v; int cups[n]; for (int i = 0; i < int(n); ++i) { cin >> cups[i]; } sort(cups, cups + n); int cup = 0; for (int i = 0; i < int(n - 1); ++i) { cup += cups[i]; if (cup > v) { cout << "NO"; return 0; } } cout << "YES"; return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 2000000000; static inline int Rint() { struct X { int dig[256]; X() { for (int i = '0'; i <= '9'; ++i) dig[i] = 1; dig['-'] = 1; } }; static X fuck; int s = 1, v = 0, c; for (; !fuck.dig[c = getchar()];) ; if (c == '-') s = 0; else if (fuck.dig[c]) v = c ^ 48; for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48)) ; return s ? v : -v; } template <typename T> static inline void cmax(T& a, const T& b) { if (b > a) a = b; } template <typename T> static inline void cmin(T& a, const T& b) { if (b < a) a = b; } int data[105]; int main() { int n = Rint(), s = Rint(); for (int i = (0); i < (n); ++i) data[i] = Rint(); int sum = accumulate(data, data + n, 0); int m = *max_element(data, data + n); puts(s >= sum - m ? "YES" : "NO"); return 0; }
#include <bits/stdc++.h> int main() { int n, s; scanf("%d%d", &n, &s); int i, a, sum = 0, max = 0; for (i = 0; i < n; i++) { scanf("%d", &a); sum += a; max = max > a ? max : a; } if (sum - max <= s) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, c = 0, p, k = 0; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) { scanf("%d", &p); c = c + p; if (p >= k) k = p; } if ((c - k) <= m) printf("YES\n"); else printf("NO\n"); }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, i, a, sum, m; scanf("%d%d", &n, &s); for (i = 0, sum = 0, m = 0; i < n; i++) { scanf("%d", &a); sum += a; m = a > m ? a : m; } if (sum - m > s) printf("NO\n"); else printf("YES\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int n, x, i, a[1001], v, y, mx = -1; string s, k; int main() { cin >> n >> v; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) { if (a[i] > mx) mx = a[i]; } for (i = 0; i < n; i++) { x = x + a[i]; } if (v < x - mx) cout << "NO"; else cout << "YES"; }
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) int n, s; int d[109]; int sum; int main() { cin >> n >> s; for (int i = 0; i < n; i++) cin >> d[i]; for (int i = 0; i < n; i++) sum += d[i]; for (int i = 0; i < n; i++) if (sum - d[i] <= s) { cout << "YES"; return 0; }; cout << "NO" << endl; return 0; };
#include <bits/stdc++.h> int main() { int x, y, j, i, a[100], m; while (~scanf("%d%d", &x, &y)) { j = 0; for (i = 0; i < x; i++) { scanf("%d", &a[i]); if (i == 0) m = a[i]; else if (m < a[i]) m = a[i]; j += a[i]; } if ((j - m) <= y) printf("YES\n"); else printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 22; const int INF = 1e9 + 2; long long n, m, ans = 0; int x, y = 0; bool sw; string str; vector<int> G[MAXN]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> x; if (ans < x) ans = x; y += x; } if (y - ans <= m) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k, in[1001], sum = 0; cin >> n >> k; bool koko = false; for (int i = 0; i < n; i++) { cin >> in[i]; } sort(in, in + n); for (int i = 0; i < n - 1; i++) { k -= in[i]; } if (k >= 0) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long c, d, e, w, n; string second; double a, b; long long p[301]; int main() { cin >> n >> c; for (int i = 0; i < n; i++) { cin >> p[i]; } sort(p, p + n); for (int i = 0; i < n - 1; i++) { c -= p[i]; if (c < 0) return cout << "NO", 0; } cout << "YES"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; cin >> n >> s; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int t = 0; for (int i = 0; i < n - 1; i++) t += a[i]; if (t <= s) cout << "YES"; else cout << "NO"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, a[110], i, t = 0; scanf("%d %d", &n, &s); for (i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); for (i = 0; i < n - 1; i++) t += a[i]; if (t <= s) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; while (scanf("%d %d\n", &n, &s) != EOF) { int mx = 0, sm = 0, a; for (int i = 0; i < n; i++) { scanf("%d ", &a); mx = max(mx, a); sm += a; } sm -= mx; printf(sm > s ? "NO\n" : "YES\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; int sum, ma; cin >> n >> s; sum = 0, ma = 0; for (int i = 0; i < n; i++) { int t; cin >> t; sum += t; if (ma < t) ma = t; } if (sum - ma <= s) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s, a[110]; scanf("%d %d", &n, &s); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); int sum = 0; for (int i = 0; i < n - 1; i++) sum += a[i]; if (sum <= s) printf("YES"); else printf("NO"); return 0; }
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const long long INF = 1ll << 60; const double pi = acos(-1); const double eps = 1e-9; const long long mod = 1e9 + 7; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int n, m; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; int S = 0, M = 0; for (int i = 0; i < n; i++) { int x; cin >> x; S += x; M = max(M, x); } if (S - M <= m) cout << "YES" << endl; else cout << "NO" << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, vol, sum = 0, mx = INT_MIN; cin >> n >> vol; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; mx = max(mx, v[i]); sum += v[i]; } if (sum - mx <= vol) { cout << "YES\n"; } else { cout << "NO\n"; } }
#include <bits/stdc++.h> using namespace std; int main(void) { int s, n, a; scanf("%d %d\n", &s, &n); vector<int> v; v.assign(s, 0); for (int i = 0; i < s; i++) scanf(" %d", &v[i]); sort(v.begin(), v.end()); bool p = true; for (int i = 0; i < s - 1; i++) { if ((n - v[i]) >= 0) n -= v[i]; else { p = false; break; } } if (p) printf("YES\n"); else printf("NO\n"); }
#include <bits/stdc++.h> using namespace std; int main() { int n, c, it, itmax = 0, sum = 0; cin >> n >> c; for (int i = 0; i < n; i++) { cin >> it; sum += it; if (it > itmax) itmax = it; } if (sum - itmax <= c) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, s; while (scanf("%d%d", &n, &s) != EOF) { int vet[n]; for (int i = 0; i < n; i++) { scanf("%d", &vet[i]); } sort(vet, vet + n); int sum = 0; for (int i = 0; i < n - 1; i++) sum += vet[i]; if (sum <= s) printf("YES\n"); else printf("NO\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const long long INF = 1000000007; const long long INF2 = 1000000007LL * 1000000007LL; const long double EPS = 1e-9; const int SIZE = 2001; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, s; cin >> n >> s; vector<int> v(n); for (int& i : v) cin >> i; sort(begin(v), end(v)); v.pop_back(); for (int& i : v) s -= i; cout << (s >= 0 ? "YES" : "NO"); return 0; }
#include <bits/stdc++.h> using namespace std; int _sortInt(const void *p1, const void *p2) { int v1 = *((int *)p1); int v2 = *((int *)p2); if (v1 == v2) return 0; if (v1 > v2) return 1; return -1; } void _solve() { int i, n, s, sum, t; vector<int> a; scanf("%d %d", &n, &s); a.resize(n); for (i = 0; i < n; i++) scanf("%d", &a[i]); qsort(&*a.begin(), a.size(), sizeof(int), &_sortInt); sum = 0; for (i = 0; i < (n - 1); i++) sum += a[i]; if (sum <= s) printf("YES"); else printf("NO"); } int main() { _solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, s; cin >> n >> s; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); int sum = 0; for (int i = 0; i < n - 1; i++) sum += arr[i]; if (sum <= s) cout << "YES"; else cout << "NO"; }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long inf = 10000000; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline bool isLeapYear(long long year) { return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0); } inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); } inline long long modMul(long long a, long long b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a * b) % MOD; } inline long long modAdd(long long a, long long b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a + b) % MOD; } inline long long modSub(long long a, long long b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; } inline long long modPow(long long b, long long p) { long long r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; } inline long long modInverse(long long a) { return modPow(a, MOD - 2); } inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); } inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL << i); ; } inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); } int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; void input(long long n, const long long a[], int co = 0) { long long i = 1; for (; i <= n; i++) { } } void dfs() {} bool cmp() {} int main() { int n, k = 0, m, x, sm = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> x; sm += x; k = max(k, x); } sm -= k; cout << (sm <= m ? "YES" : "NO"); }