希望更丰富的展现?使用Mark♂down
by aminoas @ 2019-03-28 18:32:43
希望更丰富的展现?使用Markdown
by HYSK_残雪 @ 2019-03-28 18:33:50
```
include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,a,b,sum=0,s=0;
map<int,int> vc;
map<int,int>::iterator iter;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>a>>b;
vc[a]=b;
}
for(iter=vc.begin();iter!=vc.end();iter++)
{
if(iter->second+sum>=n)
{
s+=(n-sum)*iter->first;
break;
}
else
{
s+=iter->first*iter->second;
sum+=iter->second;
}
}
vc.clear();
cout<<s<<endl;
return 0;
}
```
by HYSK_残雪 @ 2019-03-28 18:34:10
@[HYSK_残雪](/space/show?uid=65671) 找到你了
by 落寞者 @ 2019-03-28 18:36:21
@[2018J1605](/space/show?uid=143834) 嗯,第一次发贴求助,不知道怎么弄,现在知道了,谢谢大佬
by 彭小白 @ 2019-03-28 18:37:07
~~~cpp#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,a,b,sum=0,s=0;
map<int,int> vc;
map<int,int>::iterator iter;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>a>>b;
vc[a]=b;
}
for(iter=vc.begin();iter!=vc.end();iter++)
{
if(iter->second+sum>=n)
{
s+=(n-sum)*iter->first;
break;
}
else
{
s+=iter->first*iter->second;
sum+=iter->second;
}
}
vc.clear();
cout<<s<<endl;
return 0;
}
~~~
这样是吧
by 彭小白 @ 2019-03-28 18:41:01
@[彭小白](/space/show?uid=195861) ~~第一次?你这怎么也是第二个帖子了~~
by SSerxhs @ 2019-03-28 18:42:55
@[SSerxhs](/space/show?uid=29826) 同一个题,不算一个帖子?好吧,这算第二次
by 彭小白 @ 2019-03-28 18:55:29