Solution – 31A – Worms Evolution – codeforces

April 3, 2016 § Leave a comment

//c++
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,arr[1001],x,y;
    cin>>n;
    for(int i=0 ; i<n ; i++)
        cin>>arr[i];
    for(int i=0 ; i<n ; i++)
    {
        for(int j=i+1 ; j<n ;j++)
        {
            x=arr[i]+arr[j];
            y=abs(arr[i]+arr[j]);
            for(int z=0 ; z<n ; z++)
            {
                if(x==arr[z])
                {cout<<z+1<<" "<<j+1<<" "<<i+1; return 0;}
                if(y==arr[z])
                {cout<<z+1<<" "<<j+1<<" "<<i+1; return 0;}
            }

        }
    }
    cout<<"-1"<<endl;
    return 0;

}

Find more from my submissions HERE

Advertisements

Tagged: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Solution – 31A – Worms Evolution – codeforces at Orange Notes.

meta

%d bloggers like this: