Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <string>
- #include <algorithm>
- using namespace std;
- ifstream cin("baseball.in");
- ofstream cout("baseball.out");
- int n;
- int a[1001];
- int s=0;
- int main(){
- cin>>n;
- for(int i=0;i<n;i++){
- cin>>a[i];
- }
- sort(a,a+n);
- for(int i=0;i<n;i++){
- for(int j=i+1;j<n;j++){
- for(int k=j+1;k<n;k++){
- if(a[j]-a[i]<=a[k]-a[j] && 2*(a[j]-a[i])>=a[k]-a[j])s++;
- }
- }
- }
- cout<<s<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement