Advertisement
Guest User

Untitled

a guest
Dec 20th, 2013
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. ifstream cin("baseball.in");
  7. ofstream cout("baseball.out");
  8. int n;
  9. int a[1001];
  10. int s=0;
  11. int main(){
  12.     cin>>n;
  13.     for(int i=0;i<n;i++){
  14.         cin>>a[i];
  15.     }
  16.     sort(a,a+n);
  17.     for(int i=0;i<n;i++){
  18.         for(int j=i+1;j<n;j++){
  19.             for(int k=j+1;k<n;k++){
  20.                 if(a[j]-a[i]<=a[k]-a[j] && 2*(a[j]-a[i])>=a[k]-a[j])s++;
  21.             }
  22.         }
  23.     }
  24.     cout<<s<<endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement