fork download
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int N, L, R;
  6. int a[1000007];
  7.  
  8. main(){
  9. cin >> N >> L >> R;
  10. for (int i = 1; i <= N; i++) {
  11. cin >> a[i];
  12. }
  13.  
  14. int sum = 1000000;
  15. for(int i = 1; i <= N; i++) {
  16. for (int j = 1; j <= N; j++) {
  17. if (i == j) continue;
  18. int tong = a[i] + a[j];
  19. if (L <= tong and tong <= R) {
  20. sum = min(sum, tong);
  21. }
  22. }
  23. }
  24.  
  25. cout << sum;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
5 5 9
8 1 2 2 5
stdout
6