Untitled
unknown
c_cpp
a year ago
366 B
3
Indexable
#include <iostream> #include <algorithm> using namespace std; int main() { int n; cin >> n; long long niza[n], naj = 0, sum = 0; for(int i= 0; i < n; i++) { cin >> niza[i]; sum += niza[i]; naj = max(naj, niza[i]); } sum -= naj; if(naj > sum) { cout << naj * 2 << endl; } else { cout << sum + naj << endl; } return 0; }
Editor is loading...
Leave a Comment