Skip to content

Commit be10c11

Browse files
Create Greedy-PP2.c
1 parent 1935279 commit be10c11

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Greedy-Algorithms/Greedy-PP2.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<stdio.h>
2+
void sort(int a[],int n)
3+
{
4+
int t;
5+
for(int i=0;i<n-1;i++)
6+
{
7+
for(int j=0;j<n-1-i;j++)
8+
{
9+
if(a[j]>a[j+1])
10+
{
11+
t=a[j];
12+
a[j]=a[j+1];
13+
a[j+1]=t;
14+
}
15+
}
16+
}
17+
}
18+
int main()
19+
{
20+
int n,c,ans=0;
21+
scanf("%d",&n);
22+
int g[n];
23+
for(int i=0;i<n;i++)
24+
scanf("%d",&g[i]);
25+
scanf("%d",&c);
26+
int s[c];
27+
for(int i=0;i<c;i++)
28+
scanf("%d",&s[i]);
29+
sort(g,n);
30+
sort(s,c);
31+
for(int i=0;i<n;i++)
32+
{
33+
if(s[i] >= g[i])
34+
ans++;
35+
}
36+
printf("%d",ans);
37+
}

0 commit comments

Comments
 (0)