Submission #6062472


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif

//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;

const int N=1e6+6;


int main(){
    fastio;
    srng;
    int n;
    cin>>n;
    vector<pir> v;
    FOR(i,n){
        int a,b;
        cin>>a>>b;
        v.push_back({b,a});
    }
    sort(all(v));
    reverse(all(v));
    int tv=INT_MAX;
    FOR(i,n){
        tv=min(v[i].fr,tv);
        tv-=v[i].sc;
        if (tv<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - Megalomania
User Abelyan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1476 Byte
Status AC
Exec Time 52 ms
Memory 2420 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 32
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sub1_01.txt AC 1 ms 256 KB
sub1_02.txt AC 50 ms 2420 KB
sub1_03.txt AC 20 ms 1400 KB
sub1_04.txt AC 50 ms 2420 KB
sub1_05.txt AC 1 ms 256 KB
sub1_06.txt AC 1 ms 256 KB
sub1_07.txt AC 48 ms 2420 KB
sub1_08.txt AC 48 ms 2420 KB
sub1_09.txt AC 1 ms 256 KB
sub1_10.txt AC 50 ms 2420 KB
sub1_11.txt AC 49 ms 2420 KB
sub1_12.txt AC 2 ms 384 KB
sub1_13.txt AC 2 ms 256 KB
sub1_14.txt AC 29 ms 1400 KB
sub1_15.txt AC 8 ms 640 KB
sub1_16.txt AC 52 ms 2420 KB
sub1_17.txt AC 6 ms 640 KB
sub1_18.txt AC 7 ms 640 KB
sub1_19.txt AC 2 ms 384 KB
sub1_20.txt AC 49 ms 2420 KB
sub1_21.txt AC 49 ms 2420 KB
sub1_22.txt AC 50 ms 2420 KB
sub1_23.txt AC 10 ms 892 KB
sub1_24.txt AC 1 ms 256 KB
sub1_25.txt AC 1 ms 256 KB
sub1_26.txt AC 1 ms 256 KB
sub1_27.txt AC 2 ms 384 KB
sub1_28.txt AC 49 ms 2420 KB
sub1_29.txt AC 49 ms 2420 KB