标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4103 Accepted Submission(s): 1077
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 5 using namespace std; 6 7 const int maxn=100000+10; 8 9 struct Node 10 { 11 int time,level; 12 }; 13 14 Node mac[maxn]; 15 Node task[maxn]; 16 17 bool cmp(Node a,Node b) 18 { 19 if(a.time==b.time) 20 return a.level>b.level; 21 return a.time>b.time; 22 } 23 24 inline int ret(int x) 25 { 26 return task[x].time*500+task[x].level*2; 27 } 28 29 int cnt[105]; 30 31 int main() 32 { 33 int M,N; 34 while(~scanf("%d%d",&N,&M)) 35 { 36 for(int i=1;i<=N;i++) 37 { 38 scanf("%d%d",&mac[i].time,&mac[i].level); 39 } 40 41 for(int i=1;i<=M;i++) 42 { 43 scanf("%d%d",&task[i].time,&task[i].level); 44 } 45 46 sort(mac+1,mac+N+1,cmp); 47 sort(task+1,task+M+1,cmp); 48 49 int ans=0; 50 long long sum=0; 51 52 memset(cnt,0,sizeof(cnt)); 53 54 int j=1; 55 for(int i=1;i<=M;i++) 56 { 57 while(j<=N&&mac[j].time>=task[i].time) 58 { 59 cnt[mac[j].level]++; 60 j++; 61 } 62 for(int k=task[i].level;k<=100;k++) 63 { 64 if(cnt[k]) 65 { 66 cnt[k]--; 67 sum+=(long long)ret(i); 68 ans++; 69 break; 70 } 71 } 72 } 73 printf("%d %I64d\n",ans,sum); 74 } 75 return 0; 76 }
标签:
原文地址:http://www.cnblogs.com/-maybe/p/4589842.html