結果

問題 No.1570 Blocks
ユーザー the-xin
提出日時 2021-06-27 14:20:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 69,888 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 11:35:31
合計ジャッジ時間 3,439 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e6+10;
struct Node{
	LL a,b;
	bool operator<(const Node &A)const{
		return a+b<A.a+A.b;
	}
}node[N];
int main(){
	int n;
	scanf("%d",&n);
	LL sum=0;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&node[i].a,&node[i].b);
	}
	sort(node+1,node+1+n);
	int flag=1;
	for(int i=1;i<=n;i++){
		if(node[i].b<sum)flag=0;
		sum+=node[i].a;
	}
	if(flag)puts("Yes");
	else puts("No");
	return 0;
}
0