思路:反悔贪心
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<iostream>
using namespace std;
int c[100005];
int w[100005];
int v[100005];
int ansa[100005],ansb[100005];
struct S{
int id;
bool operator<(S x)const{
return v[id]>v[x.id];
}
};
priority_queue<S> pq;
int ans=0;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//优化
int n,m;
cin>>n>>m;
S tmp1;
for(int i=1;i<=n;i++)cin>>c[i];
for(int i=1;i<=n;i++)cin>>w[i];
for(int i=1;i<=n;i++)v[i]=(100-((c[i]-1)%100+1))*w[i];
for(int i=1;i<=n;i++){
int tmp=c[i]%100;
if(tmp<=m){
m-=tmp;
tmp1.id=i;
pq.push(tmp1);
ansa[i]=c[i]/100;
ansb[i]=tmp;
}else{
if(pq.empty()){
ansa[i]=c[i]/100+1;
ansb[i]=0;
ans+=v[i];
m+=100-tmp;
}
else{
int p=pq.top().id;
if(v[p]!=0&&v[i]>v[p]||v[i]==v[p]&&w[i]<w[p]){
pq.pop();
tmp1.id=i;
pq.push(tmp1);
ans+=v[p];
m+=100-tmp;
ansa[p]++,ansb[p]=0,ansa[i]=c[i]/100,ansb[i]=tmp;
}else{
ansa[i]=c[i]/100+1,ansb[i]=0;
ans+=v[i];
m+=100-tmp;
}//c[i]%100不可能为0
}
}
}
cout<<ans<<'\n';
for(int i=1;i<=n;i++)cout<<ansa[i]<<' '<<ansb[i]<<'\n';
return 0;
}