- ACM
这题为何报错
- 5 months ago @
0 comments
No comments so far...
#include<iostream>
#include<algorithm>
using namespace std;
int n,l;
long long a[10005]
long long b[10005];
int main()
{
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
sort(a,a+n);
sort(b,b+n);
for(int i=0;i<n;i++)
{
l+=b[i]-a[i];
if(i+1<n)
if(b[i]>a[i+1])
l-=b[i]-a[i+1];
}
cout<<l;
return 0;
}
By signing up a 美力程青少儿编程 universal account, you can submit code and join discussions in all online judging services provided by us.