Attend class
Title Description
There are many school classes, the \ (i \) lesson from (t_i \) \ on the start time, class time is \ (S_I \) , if on the first \ (i \) class, you do capacity problems will become \ (C_i \) (numerical ability, not the ability to increase the value). There \ (N \) class operation, not the number of jobs each type, each type of operation required to complete a time \ (a_i \) , do the work needed to make certain types of problems capacity \ (q_i (> = q_i ) \) to complete. In every moment you can choose classes, rest, do homework, if you select the class you must complete the lesson, if you choose to spend doing homework must complete \ (a_i \) time to do the same time only a lesson or do one job. And a person's energy is limited, in \ (T \) must stop learning after time (probably part of the lesson to \ (T \) after the time). Request can be completed within the time limit up to several jobs. In the beginning, you do question the capacity of \ (1 \) , for the moment \ (1 \) .
Input formats:
The first row of three integers \ (T \) , \ (M \) , \ (N \) , represents the total time, there are \ (M \) class, there are \ (N \) class job.
Next \ (M \) each row three rows integer \ (t_i \) , \ (S_I \) , \ (C_i \) .
Next \ (N \) each row lines two integers \ (a_i \) , \ (Q_I \) .
Output formats:
Total row, an integer \ (ANS \) , represents the most complete several jobs within the time limit.
Sample input:
10 1 2 3 2 5 4 1 1 3
Sample output:
6
data range:
\ (20% \) data satisfies \ (M, N <=. 4 \) , \ (T <= 15 \) .
\ (50% \) data satisfies \ (M <= 100 \) , \ (N <= 1000 \) , \ (T <= 1000 \) .
\ (100% \) data satisfies \ (M <= 1000 \) , \ (N <= 100000 \) , \ (T <= 100000 \) , \ (. 1 <= C_i <= 100 \) , \ ( . 1 <= a_i \) , \ (t_i <= T \) , \ (. 1 <= Q_I <= 100 \) .
time limit:
1S
Space limitations:
64M
prompt:
remove!!!
answer
There \ (N \) lessons, each lesson can you do question the ability (IQ) becomes a value.
You \ (M \) kinds of jobs, take some time and some do question the ability. (At first I thought each topic can only be done once, like a long o (╥﹏╥) o)
because each job takes "time" added value is fixed at 1
so we can out of each pre-treatment capacity 1 part of doing the job requires a minimum amount of time.
memset(mn,0x3f,sizeof(mn));
for(int j=1;j<=n;j++){
scanf("%d%d",&x,&y);
mn[y]=min(mn[y],x);
}
for(int j=1;j<=102;j++)
mn[j]=min(mn[j],mn[j-1]);
We see \ (M \) range only \ (1000 \) then we can look at the dp.
\ (dp [j] \) represents the first \ (j \) to do more work can be done much before the lesson.
Such enumeration \ (j \) on each lesson before homework has been finished to the first \ (j \) lesson before how much do the job on the line.
Transfer equation is: \ (DP [J] = max (DP [J], DP [I] + \ A {FRAC [J] .ta [I] .ta [I] .s} {Mn [A [I] .c]} \)
on Code:
#include<bits/stdc++.h>
#define inf 1e9
using namespace std;
int t,n,m;
int x,y;
struct aa{
int t,s,c;
}a[1009];
int mn[119];
int dp[1009];
bool cmp(aa x,aa y){
return x.t<y.t;
}
int main(){
memset(mn,0x3f,sizeof(mn));
scanf("%d%d%d",&t,&m,&n);
for(int j=1;j<=m;j++)
scanf("%d%d%d",&a[j].t,&a[j].s,&a[j].c);
m++;
a[m].t=t+1;
sort(a+1,a+m+1,cmp);
a[0].t=a[0].c=1;
for(int j=1;j<=n;j++){
scanf("%d%d",&x,&y);
mn[y]=min(mn[y],x);
}
for(int j=1;j<=102;j++)
mn[j]=min(mn[j],mn[j-1]);
for(int j=1;j<=m;j++){
for(int i=0;i<j;i++){
if(a[i].t+a[i].s-1>=a[j].t) continue;
dp[j]=max(dp[j],dp[i]+(a[j].t-a[i].t-a[i].s)/mn[a[i].c]);
}
}
printf("%d\n",dp[m]);
return 0;
}