can anyone help me in this
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long int
struct points{
ll a;
ll b;
};
int cos(points x , points y)
{
return x.b<y.b;
}
int main()
{
ll n,r,avg,i,j,k;
points pt[100005];
cin>>n>>r>>avg;
for(i=0;i<n;i++)
{
cin>>pt[i].a>>pt[i].b;
}
sort(pt,pt+n,cos);
ll sum=avg*n;
for(i=0;i<n;i++)sum-=pt[i].a;
if(sum<=0)cout<<"0\n";
else
{
ll ans=0;
for(i=0;i<n;i++)
{
if(sum==0)break;
else
{
if(sum>r-pt[i].a)
{
ans=ans+pt[i].b*(r-pt[i].a);
sum=sum-(r-pt[i].a);
}
else
{
ans=ans+sum*pt[i].b;
sum-=sum;
}
}
}
cout<<ans<<endl;
}
return 0;
}
when im compiling in my system its working fine and getting the correct output but when i'm submitting in codeforces under GNUC++ 11 im getting compllation error? can u help me
Aucun commentaire:
Enregistrer un commentaire