fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. bool ans = false;
  7. cin >> N;
  8. vector<int>A(109);
  9. for(int i=1; i<=N; i++){
  10. cin >> A[i];
  11. }
  12. for(int i=1; i<=N; i++){
  13. for(int j=i+1; j<=N; j++){
  14. for(int k=j+1; k<=N; k++){
  15. if(A[i]+A[j]+A[k]==1000){
  16. ans = true;
  17. break;
  18. }
  19. }
  20. }
  21. }
  22. if(ans){
  23. cout << "Yes";
  24. }else{
  25. cout << "No";
  26. }
  27. // your code goes here
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5296KB
stdin
5
100 250 350 400 600
stdout
Yes