求大神看看,为什么超内存提示!!!!cout<<20<<endl交上去测试了下能通过一个case啊!!! #include "iostream" #include "string" #include "cstdio" #include "cstring" #include "map" #include "algorithm" using namespace std; struct customer {     int count;     int money; }; customer cus[ 50000 ]; int cmp(customer a,customer b) {     return a.money>b.money; } int main() {     int n,m;     while (cin>>n>>m)     {         memset(cus, 0 , sizeof (cus));         map< int , int > table;         int mx= 0 ;         for ( int i= 0 ;i<n;++i)         {             int a;             cin>>a;             if (mx<a) mx=a;             table[a]++;         }                           for ( int i= 0 ;i<m;++i)             cin>>cus[i].count>>cus[i].money;                           long long int res= 0 ;         sort(cus,cus+m,cmp);         for ( int i= 0 ;i<m;++i)         {             for ( int k=cus[i].count;k<=mx;++k)             {                 if (table[k]> 0 )                 {                     res+=cus[i].money;                     table[k]--;                     break ;                 }             }         }                  cout<<res<<endl;     }     return 0 ; }
点赞 5

相关推荐

04-13 18:10
门头沟学院 Java
想熬夜的小飞象在秋招:被腾讯挂了后爸妈以为我失联了
点赞 评论 收藏
分享
叶扰云倾:进度更新,现在阿里云面完3面了,感觉3面答得还行,基本都答上了,自己熟悉的地方也说的比较细致,但感觉面试官有点心不在焉不知道是不是不想要我了,求阿里收留,我直接秒到岗当阿里孝子,学校那边的房子都退租了,下学期都不回学校,全职猛猛实习半年。这种条件还不诱人吗难道 然后现在约到了字节的一面和淘天的复活赛,外加猿辅导。华为笔试完没动静。 美团那边之前投了个base广州的,把我流程卡麻了,应该是不怎么招人,我直接简历挂了,现在进了一个正常的后端流程,还在筛选,不知道还有没有hc。
点赞 评论 收藏
分享
我知道自己这个念头不好,但是真的很羡慕😭大家的父母长辈都能帮到自己吗?
大飞的诡术妖姬:父母都是普通打工人,身体也不好,能供我读到本科毕业很不容易,毕业以后帮衬心里会有罪恶感。虽然可能会错过很多风景,但还是想活的心安理得。
点赞 评论 收藏
分享
牛客网
牛客企业服务