#include "stdafx.h"
#include<iostream>
using namespace std;
int GreedySelect(int *s,int *f,int length,int *a)
{
a[1]=1;
int k=1;
int j=2;
for(int m=2;m<=length;m++)
{
if(s[m]>=f[k])
{
a[j++]=m;
k=m;
}
}
return j;
}
int _tmain(int argc, _TCHAR* argv[])
{
int s[12]={0,1,3,0,5,3,5,6,8,8,2,12};
int f[12]={0,4,5,6,7,9,9,10,11,12,14,16};
int a[100];
int k=GreedySelect(s,f,11,a);
for(int j=1;j<k;j++)
cout<<a[j]<<endl;
return 0;
}
11-26
1289
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-09
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交