結果
問題 | No.1570 Blocks |
ユーザー |
|
提出日時 | 2021-06-27 14:52:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 103 ms / 2,000 ms |
コード長 | 546 bytes |
コンパイル時間 | 2,342 ms |
コンパイル使用メモリ | 199,400 KB |
最終ジャッジ日時 | 2025-01-22 14:25:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (n); ++i)#define fi first#define se secondusing std::cin;using std::cout;using std::pair;using std::vector;using ll = long long;using P = pair<ll, ll>;int main() {int n;cin >> n;vector<P> a(n);rep(i, n) cin >> a[i].first >> a[i].se;sort(a.begin(), a.end(), [&](P c, P d) {return c.fi + c.se < d.fi + d.se;});ll s = 0;bool ok = true;rep(i, n) {if (a[i].se < s) ok = false;s += a[i].fi;}cout << (ok ? "Yes\n" : "No\n");return 0;}