-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path230A.c
More file actions
51 lines (45 loc) · 780 Bytes
/
230A.c
File metadata and controls
51 lines (45 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <string.h>
int main()
{
int s,n,i,j,count=0;
scanf("%d %d",&s,&n);
int x[1000],y[1000];
for (i=0;i<n;i++)
{
scanf("%d %d",&x[i],&y[i]);
}
int temp = 0 , temp2=0 ;
for (i=0;i<n;i++)
{
for (j=i+1;j<n;j++)
{
if (x[i]>x[j])
{
temp = x[i];
x[i] = x[j];
x[j] = temp;
temp = y[i];
y[i] = y[j];
y[j] = temp;
}
}
}
for (i=0;i<n;i++)
{
if (s>x[i])
{
count++;
s=s+y[i];
}
}
if (count==n)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
return 0;
}