結果

問題 No.1570 Blocks
ユーザー 👑 Nachia
提出日時 2021-06-27 13:39:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 78,872 KB
最終ジャッジ日時 2025-01-22 14:05:14
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
vector<pair<ll,ll>> A;

int main(){
  cin >> N;
  A.resize(N);
  rep(i,N) cin >> A[i].second >> A[i].first;
  ll sumW = 0;
  rep(i,N) sumW += A[i].second;
  rep(i,N) A[i].first = sumW - A[i].first - A[i].second;
  sort(A.begin(),A.end());
  ll nowsumW = 0;
  rep(i,N){
    if(nowsumW < A[i].first){ cout << "No\n"; return 0; }
    nowsumW += A[i].second;
  }
  cout << "Yes\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0