?? 4565120_ce.cpp
字號:
#include<iostream>
#include<stdlib.h>
using namespace std;
short n;
short t;
short k;
/*struct gan
{
short time;
short pro;
short need;
};
gan x[100];*/
short time[105];
short pro[105];
short need[105];
short input[105][30005];
short p[105][105];
short compare(const void *p1,const void *p2)
{
short temp1=*(short *)p1;
short temp2=*(short *)p2;
return temp1-temp2;
}
short get(short a,short b)
{
if(a>=0&&a<n&&b>=0&&b<=k) return p[b][a];
else return 0;
}
void tian(short a,short b,short now)
{
short dt;
if(now==0) dt=time[now];
else dt=time[now]-time[now-1];
short max=0;
for(short count=b-dt;count<=b+dt;count++)
{
if(get(a-1,count)>max) max=get(a-1,count);
}
p[b][a]=max+input[b][time[now]];
}
int main()
{
cin>>n>>k>>t;
for(short count=0;count<n;count++) cin>>time[count];
for(short count2=0;count2<n;count2++) cin>>pro[count2];
for(short count3=0;count3<n;count3++) cin>>need[count3];
//qsort(x,n,sizeof(struct gan),compare);
//hebing();
memset(input,0,sizeof(input));
for(short count4=0;count4<n;count4++)
{
input[need[count4]][time[count4]]+=pro[count4];
}
qsort(time,n,sizeof(short),compare);
short a=0;
for(short count5=0;count5<n;count5++)
{
if(count5!=0&&time[count5]==time[count5-1])
{
continue;
}
else
{
for(short count6=0;count6<=k;count6++)
{
tian(a,count6,count5);
}
a++;
}
}
short max=0;
/*
for(short tiao2=0;tiao2<=k;tiao2++)
{
for(short tiao1=0;tiao1<a;tiao1++)
cout<<p[tiao2][tiao1]<<" ";
cout<<endl;
}
*/
for(short count7=0;count7<=k;count7++)
{
if(p[count7][a-1]>max) max=p[count7][a-1];
}
cout<<max;
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -