DevilsFlame @ 2024-02-02 10:51:12
rt
于是我的代码成了这样子:
#include <bits/stdc++.h>
using namespace std;
int n,m,s,l,r,minn=99999,ans1,ans2,w[1001],v[1001],vv;
int q[100001];
void gg(int x){
ans1=0,ans2=0;
for(int i=1;i<=n;i++)
if(w[i]>x){
ans1++;
ans2+=v[i];
}
// cout<<ans1<<' '<<ans2<<endl;
return;
}
int main(){
// cout<<abs(15-110);
cin>>n>>m>>s;
for(int i=1;i<=n;i++){
cin>>w[i]>>v[i];
}
for(int i=1;i<=m;i++){
cin>>l>>r;vv=0;
for(int j=l;j<=r;j++){
if(q[j]){
vv+=q[j];
continue;
}
gg(j);
int ans3=abs(s-ans1*ans2);
q[j]=ans3;
vv+=ans3;
}
vv=abs(s-vv);
minn=min(minn,vv);
}
cout<<minn<<endl;
return 0;
}