Skip to content

Commit 89b0181

Browse files
committed
new one
1 parent b2530ad commit 89b0181

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

worms_evolution.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
ios::sync_with_stdio(false);
7+
cin.tie(0);
8+
int n;
9+
cin>>n;
10+
vector <int> v;
11+
int element;
12+
for(int i=0;i<n;i++) {
13+
cin>>element;v.push_back(element);
14+
}
15+
int sum=0;
16+
for(auto i=v.begin();i!=v.end();i++) {
17+
for(auto j=i+1;j!=v.end();j++)
18+
{
19+
sum=*i+*j;
20+
if(find(v.begin(),v.end(),sum)!=v.end())
21+
{
22+
cout<<find(v.begin(),v.end(),sum)-v.begin()+1<<" "<<i-v.begin()+1<<" "<<j-v.begin()+1<<" "<<endl;
23+
return 0;
24+
}
25+
}
26+
}
27+
cout<<"-1"<<endl;
28+
return 0;
29+
}

0 commit comments

Comments
 (0)