Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define el endl
- #define ll long long
- #define umi unordered_map<int, int>
- #define umll unordered_map<ll, ll>
- #define all(vect) vect.begin(), vect.end()
- #define reset(A) memset(A, 0, sizeof(A))
- #define approx(n) fixed << setprecision(n)
- #define pb push_back
- const int mod = 1e9 + 7;
- void solve() {
- ll n;
- cin >> n;
- ll a[n + 1];
- ll minn = 0;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- if(a[minn] > a[i]) {
- minn = i;
- }
- }
- ll min2 = 0;
- if(minn == 0) {
- min2 = 1;
- }
- for(int i = 0; i < n; i++) {
- if(i != minn) {
- if(a[min2] > a[i])
- min2 = i;
- }
- }
- ll min3 = 0;
- for(int i = 0; i < n; i++) {
- if(i != minn && i != min2) {
- if(a[min3] > a[i])
- min3 = i;
- }
- }
- cout << (a[minn] + a[min3] + a[min2]) << el;
- }
- int main() {
- int t = 1;
- cin >> t;
- // cin.ignore();
- while(t--) {
- solve();
- }
- return 0;
- }
- /*
- 2
- 7
- 1 2 3 0 -1 8 10
- 9 8 20 3 4 -1 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement