結果

問題 No.1570 Blocks
ユーザー hiro71687khiro71687k
提出日時 2023-03-10 20:20:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 4,489 ms
コンパイル使用メモリ 267,108 KB
実行使用メモリ 8,776 KB
最終ジャッジ日時 2023-10-18 06:48:04
合計ジャッジ時間 12,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 67 ms
7,028 KB
testcase_03 AC 72 ms
7,556 KB
testcase_04 AC 58 ms
6,132 KB
testcase_05 AC 62 ms
6,180 KB
testcase_06 AC 54 ms
6,468 KB
testcase_07 AC 10 ms
4,348 KB
testcase_08 AC 71 ms
7,524 KB
testcase_09 AC 82 ms
7,988 KB
testcase_10 AC 76 ms
7,436 KB
testcase_11 AC 84 ms
7,548 KB
testcase_12 AC 85 ms
8,300 KB
testcase_13 AC 96 ms
8,776 KB
testcase_14 AC 99 ms
8,324 KB
testcase_15 AC 44 ms
5,644 KB
testcase_16 AC 97 ms
8,300 KB
testcase_17 AC 36 ms
5,596 KB
testcase_18 AC 80 ms
7,492 KB
testcase_19 AC 37 ms
5,604 KB
testcase_20 AC 44 ms
5,628 KB
testcase_21 AC 63 ms
7,116 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 82 ms
8,776 KB
testcase_33 AC 85 ms
8,316 KB
testcase_34 AC 92 ms
7,940 KB
testcase_35 AC 84 ms
8,300 KB
testcase_36 AC 95 ms
7,996 KB
testcase_37 AC 81 ms
7,964 KB
testcase_38 AC 82 ms
7,996 KB
testcase_39 AC 98 ms
8,316 KB
testcase_40 AC 95 ms
7,988 KB
testcase_41 AC 85 ms
8,308 KB
testcase_42 AC 102 ms
8,356 KB
testcase_43 AC 102 ms
8,356 KB
testcase_44 AC 102 ms
8,356 KB
testcase_45 AC 103 ms
8,356 KB
testcase_46 AC 87 ms
8,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=155550555555555;
ll mod=1000000007;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    priority_queue<pair<ll,ll>>pq;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i]>> b[i];
        pq.push({-a[i]-b[i],i});
    }
    vector<ll>c;
    while (!pq.empty())
    {
        c.push_back(pq.top().second);
        pq.pop();
    }
    ll ans=0;
    for (ll i = 0; i < n; i++)
    {
        if (ans>b[c[i]])
        {
            cout << "No" << endl;
            return 0;
        }
        ans+=a[c[i]];
    }
    cout << "Yes" << endl;
}
0