标签:os io for ef on ios sp algorithm
这道题给我wa惨了,数组元素范围分明是10^9,int完全够啊,今天改成long long 过了,求解释啊
#include<iostream> #include<stdio.h> #include<algorithm> #define N 200005 using namespace std; int main(){ long long n,a[N]; while(cin>>n){ for(long long i=0;i<n;i++) cin>>a[i]; sort(a,a+n); long long lena=1,lenb=1; for(long long i=1;i<n;i++) if(a[0]==a[i]) lena++; for(long long i=n-2;i>=0;i--) if(a[n-1]==a[i]) lenb++; if(lena==n){ long long t=0; cout<<t<<" "<<n*(n-1)/2<<endl; } else{ cout<<a[n-1]-a[0]<<" "<<lenb*lena<<endl; } } }
459B Pashmak and Flowers,布布扣,bubuko.com
标签:os io for ef on ios sp algorithm
原文地址:http://blog.csdn.net/youngyangyang04/article/details/38610391