#include<bits/stdc++.h>
using namespace std;
struct node
{
int l;
int r;
int x;
int num;
}arr[100005];
bool cmp(node x,node y)
{
if(x.x<y.x)
return true;
return false;
}
int main()
{
int n,a1=0,a2=0,num1=0,num2=0;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>arr[i].l>>arr[i].r;
arr[i].x=arr[i].l-arr[i].r;
arr[i].num=i;
if(arr[i].x>=0)
{
a1+=arr[i].x;
num1++;
}
else
{
a2+=arr[i].x;
num2++;
}
}
sort(arr+1,arr+n+1,cmp);
if(num1==1||num2==1)
{
if(arr[1].x>=0)
cout<<0<<endl;
else if(num1==1)
cout<<arr[n].num<<endl;
else
cout<<arr[1].num<<endl;
}
else if(a1>=abs(a2))
{
if(arr[1].x>=0)
cout<<0<<endl;
else
cout<<arr[1].num<<endl;
}
else
{
node temp=arr[1];
if(arr[n].x<=0)
cout<<0<<endl;
else
{
for(int i=2;i<=n;i++)
if(arr[i].x>temp.x)
temp=arr[i];
cout<<temp.num<<endl;
}
}
return 0;
}
733B Parade codeforces(水题)
最新推荐文章于 2020-04-02 10:29:03 发布