結果

問題 No.1570 Blocks
ユーザー maguromaguro
提出日時 2021-04-13 16:30:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,582 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 207,708 KB
実行使用メモリ 5,560 KB
最終ジャッジ日時 2023-09-07 17:23:16
合計ジャッジ時間 9,039 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 58 ms
4,672 KB
testcase_03 AC 59 ms
4,956 KB
testcase_04 AC 51 ms
4,384 KB
testcase_05 AC 53 ms
4,376 KB
testcase_06 AC 46 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 58 ms
4,872 KB
testcase_09 AC 67 ms
5,236 KB
testcase_10 AC 65 ms
5,180 KB
testcase_11 AC 71 ms
4,920 KB
testcase_12 AC 70 ms
5,380 KB
testcase_13 AC 82 ms
5,500 KB
testcase_14 AC 85 ms
5,528 KB
testcase_15 AC 38 ms
4,376 KB
testcase_16 AC 83 ms
5,504 KB
testcase_17 AC 30 ms
4,404 KB
testcase_18 AC 68 ms
5,000 KB
testcase_19 AC 31 ms
4,376 KB
testcase_20 AC 38 ms
4,384 KB
testcase_21 AC 53 ms
4,760 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,384 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 69 ms
5,132 KB
testcase_33 AC 71 ms
5,376 KB
testcase_34 AC 78 ms
5,136 KB
testcase_35 AC 70 ms
5,456 KB
testcase_36 AC 82 ms
5,288 KB
testcase_37 AC 67 ms
5,132 KB
testcase_38 AC 67 ms
5,300 KB
testcase_39 AC 84 ms
5,560 KB
testcase_40 AC 82 ms
5,284 KB
testcase_41 AC 70 ms
5,436 KB
testcase_42 AC 87 ms
5,432 KB
testcase_43 AC 86 ms
5,488 KB
testcase_44 AC 86 ms
5,452 KB
testcase_45 AC 86 ms
5,376 KB
testcase_46 AC 72 ms
5,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000030;
constexpr ll INF= 2000000000000000001;
constexpr ll MOD = 1000000007;
const double PI = 3.14159265358979323846;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

template<typename T> 
vector<T> make_vector(size_t s) {
    return vector<T>(s);
}

template<typename T,typename... Args>
auto make_vector(size_t s,Args... args) {
    return vector(s,make_vector<T>(args...));
}

template<typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) return 1;
    if(P < 0) return 0;
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) return N * RS(N,P - 1,M);
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<pair<ll,P>> vec(N);
    for(int i = 0;i < N;i++) {
        ll A,B;
        cin >> A >> B;
        vec.at(i) = {A + B,{A,B}};
    }
    sort(vec.begin(),vec.end());
    ll Sum = 0;
    bool ret = true;
    for(int i = 0;i < N;i++) {
        if(vec.at(i).second.second < Sum) {
            ret = false;
        }
        Sum += vec.at(i).second.first;
    }
    if(ret) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0