标签:
额...大意是你可以决定什么时候选课。然后呢。每五分钟只有一次机会选。每种课限制选课时间。问你能选到的课最多有多少、
感觉一点都不水。是自己太菜了吗?
1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 7 struct Node 8 { 9 int l, r; 10 } node[400]; 11 12 int cmp(Node a, Node b) 13 { 14 if (a.r != b.r) return a.r <b.r; 15 return a.l <= b.l; 16 } 17 18 int main() 19 { 20 int n; 21 while(cin >> n) 22 { 23 if (n == 0) break; 24 for (int i=0; i<n; ++i) 25 { 26 cin >> node[i].l >> node[i].r; 27 } 28 sort(node, node+n, cmp); 29 int ans = 0; 30 int vis[400]; 31 memset(vis, 0, sizeof(vis)); 32 33 for (int i=0; i<5; ++i) 34 { 35 int st = i; 36 int tans = 0; 37 memset(vis, 0, sizeof(vis)); 38 //for (st=i; st<=node[n-1].r; st+=5) 39 while(st <= node[n-1].r) 40 { 41 for (int j=0; j<n; ++j) 42 { 43 if (vis[j]) continue; 44 if (node[j].l < st && node[j].r >= st) 45 { 46 //st += 5; 47 vis[j] = 1; 48 tans += 1; 49 break; 50 } 51 //st += 5; 52 } 53 st += 5; 54 } 55 ans = max(ans, tans); 56 } 57 cout << ans << endl; 58 } 59 return 0; 60 }
标签:
原文地址:http://www.cnblogs.com/icode-girl/p/4725853.html