結果

問題 No.1570 Blocks
ユーザー どららどらら
提出日時 2021-06-27 13:43:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 4,009 ms
コンパイル使用メモリ 231,828 KB
実行使用メモリ 4,944 KB
最終ジャッジ日時 2023-09-07 17:41:19
合計ジャッジ時間 8,275 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 57 ms
4,388 KB
testcase_03 AC 60 ms
4,684 KB
testcase_04 AC 50 ms
4,380 KB
testcase_05 AC 54 ms
4,380 KB
testcase_06 AC 46 ms
4,380 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 59 ms
4,384 KB
testcase_09 AC 68 ms
4,412 KB
testcase_10 AC 65 ms
4,380 KB
testcase_11 AC 72 ms
4,456 KB
testcase_12 AC 70 ms
4,716 KB
testcase_13 AC 83 ms
4,620 KB
testcase_14 AC 85 ms
4,764 KB
testcase_15 AC 38 ms
4,380 KB
testcase_16 AC 83 ms
4,944 KB
testcase_17 AC 31 ms
4,380 KB
testcase_18 AC 68 ms
4,516 KB
testcase_19 AC 30 ms
4,380 KB
testcase_20 AC 38 ms
4,380 KB
testcase_21 AC 52 ms
4,376 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,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 69 ms
4,720 KB
testcase_33 AC 71 ms
4,704 KB
testcase_34 AC 79 ms
4,500 KB
testcase_35 AC 70 ms
4,916 KB
testcase_36 AC 81 ms
4,700 KB
testcase_37 AC 67 ms
4,708 KB
testcase_38 AC 68 ms
4,704 KB
testcase_39 AC 84 ms
4,620 KB
testcase_40 AC 81 ms
4,504 KB
testcase_41 AC 70 ms
4,700 KB
testcase_42 AC 86 ms
4,784 KB
testcase_43 AC 87 ms
4,704 KB
testcase_44 AC 86 ms
4,708 KB
testcase_45 AC 86 ms
4,740 KB
testcase_46 AC 73 ms
4,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
//using mint = modint998244353;

struct ST {
  ll A, B;
};
bool operator<(const ST& a, const ST& b){
  if(a.A + a.B == b.A + b.B) return a.A < b.A;
  return a.A + a.B < b.A + b.B;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v(N);
  rep(i,N){
    cin >> v[i].A >> v[i].B;
  }
  sort(ALLOF(v));

  ll W = 0;
  rep(i,v.size()){
    if(W > v[i].B){
      cout << "No" << endl;
      return 0;
    }

    W += v[i].A;
  }

  cout << "Yes" << endl;
  
  return 0;
}

0