# BZOJ1642: [Usaco2007 Nov]Milking Time 挤奶时间

## 1642: [Usaco2007 Nov]Milking Time 挤奶时间

Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 525  Solved: 300
[Submit][Status]

## Input

1行三个整数N，M，R.接下来M行，每行三个整数Si，Ei，Pi．

最大产奶量．

12 4 2
1 2 8
10 12 19
3 6 24
7 10 31

43

## HINT

 1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #include<string>
12 #define inf 1000000000
13 #define maxn 500+100
14 #define maxm 1000+100
15 #define eps 1e-10
16 #define ll long long
17 #define pa pair<int,int>
18 using namespace std;
19 inline int read()
20 {
21     int x=0,f=1;char ch=getchar();
22     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
23     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
24     return x*f;
25 }
26 ll ans,f[maxm];
27 struct rec{int s,e,p;}a[maxm];
28 int n,m,r;
29 inline bool cmp(rec a,rec b)
30 {
31     return a.s<b.s;
32 }
33 int main()
34 {
35     freopen("input.txt","r",stdin);
36     freopen("output.txt","w",stdout);
39     sort(a+1,a+m+1,cmp);
40     for(int i=1;i<=m;i++)
41      {
42          f[i]=a[i].p;
43          for(int j=1;j<=i-1;j++)
44           if(a[j].e<=a[i].s)f[i]=max(f[i],f[j]+a[i].p);
45          ans=max(ans,f[i]);
46      }
47     printf("%lld\n",ans);
48     return 0;
49 }
View Code

posted @ 2014-08-28 19:16  ZYF-ZYF  Views(141)  Comments(0Edit  收藏  举报