# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
726623 | btkhg | Race (IOI11_race) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
vector<pl> v;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for(int i=0;i<n;i++)
{
int a,b;
cin >> a >> b;
v.push_back({b, a});
}
sort(v.begin(), v.end());
ll cur = 0;
for(int i=0;i<n;i++)
{
cur += v[i].second;
if(cur > v[i].first)
{
cout << "No";
return 0;
}
}
cout << "Yes";
}