結果
| 問題 | 
                            No.1570 Blocks
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ぷら
                         | 
                    
| 提出日時 | 2021-06-27 14:24:39 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 160 ms / 2,000 ms | 
| コード長 | 617 bytes | 
| コンパイル時間 | 2,407 ms | 
| コンパイル使用メモリ | 199,724 KB | 
| 最終ジャッジ日時 | 2025-01-22 14:20:36 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 45 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<pair<int,int>>tmp(N);
    for(int i = 0; i < N; i++) {
        cin >> tmp[i].first >> tmp[i].second;
    }
    sort(tmp.begin(),tmp.end(),[](auto x,auto y) {
        if(min(x.second,y.second-x.first) < min(y.second,x.second-y.first)) {
            return false;
        }
        return true;
    });
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        if(sum > tmp[i].second) {
            cout << "No" << endl;
            return 0;
        }
        sum += tmp[i].first;
    }
    cout << "Yes" << endl;
}
            
            
            
        
            
ぷら