Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int main(){
- int n;
- cin >> n;
- long long *a = new long long ;
- for(int i=0;i<n;i++){
- cin >> a[i];
- }
- sort(a,a+n);
- for(int i=0;i<n-2;i++){
- for(int j=i+1;j<n-1;j++){
- for(int q=j+1;q<n;q++){
- if(a[i]+a[q]+a[j]==0) cout << a[i] << ' ' << a[j] << ' ' << a[q] << endl;
- while(i<n-2 && a[i]==a[i+1]) i++;
- while(j<n-1 && a[j]==a[j+1]) j++;
- while(q<n && a[q]==a[q+1]) q++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement